class
How do I create instances of cl_math such that I can access them via an arary (math[1].a etc)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
class cl_math
{
public:
int a, b;
int add()
{
return a + b;
}
};
int main()
{
//create instance of cl_math
//....
int i;
for (i=0; i<10; i++)
{
math[i].a = i*2;
math[i].b = i;
cout << math[i].a << " + " << math[i].b << " = " << math[i].add;
}
system ("pause");
return 0;
}
|
try...
1 2
|
cl_math * math;
math = new cl_math[10];
|
Topic archived. No new replies allowed.