|
-
C++ object problem
I was re-writing a program to be more object-oriented and organized, and i came upon an interesting program. I write another separate program to isolate what i was having a problem with, but that didnt help me fix it. Maybe you guys might have an idea... here is what im trying to do:
PHP Code:
#include<iostream>
using namespace std;
class TEST
{
public:
char A;
int B;
};
void Init(TEST &obj);
void Init(TEST &obj)
{
obj[1].A = 'a';
obj[1].B = 1;
}
int main()
{
TEST obj[5];
Init(obj);
cout << obj[1].A << endl;
return 0;
}
I want to be able to declare an array of objects, like maybe 100 of them. I want to pass that entire array to an Init() function that will initialize SOME of those objects, then return them to main. Not sure why it wont work =( Thanks!
-
Texan Dragon Moderator
Dragon of the OC Crusaders
Break the rules and you're snack food for this dragon...
-
wow, now i feel stupid, lol. I could have sworn that i tried that already... oh well. Thanks for the help!
-
Texan Dragon Moderator
Originally posted by yoshi273
wow, now i feel stupid, lol. I could have sworn that i tried that already... oh well. Thanks for the help!
LOL...
Don't worry 'bout that. It's the silly little stuff that will kill you in no time flat.
Dragon of the OC Crusaders
Break the rules and you're snack food for this dragon...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|