yoshi273
06-13-2002, 02:40 AM
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:
#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!
#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!