pghsteelers
Technical User
Why can you declare a pointer of type <classname> and assign it to an array of objects, but you can't assign it to individual objects without assigning it to the address of the individual object?
For example:
class CSomeClass
{
...
...
...
}
...
...
...
int main()
CSomeClass objname1;
CSomeClass objarray1[3];
CSomeClass* ptest;
ptest = &objname1; //excepted
ptest = objarray1; //excepted
ptest = objname1; //not excepted
...
...
...
return 0;
}
For example:
class CSomeClass
{
...
...
...
}
...
...
...
int main()
CSomeClass objname1;
CSomeClass objarray1[3];
CSomeClass* ptest;
ptest = &objname1; //excepted
ptest = objarray1; //excepted
ptest = objname1; //not excepted
...
...
...
return 0;
}