How to make a pointer to class and how to use it?
Like, what would the cout statements show on screen?
#include <iostream.h>
void main()
{
class CLASS
{
public:
int INT;
char CHAR;
};
CLASS OBJECT;
OBJECT.INT = 10;
OBJECT.CHAR = 'A';
CLASS *POINTER = &OBJECT;
cout << POINTER << " " << &OBJECT; //WILL THESE TWO SHOW
//THE SAME VALUE?
cout << endl << *POINTER << " " << OBJECT.INT << " " << POINTER -> INT; //WILL THESE SHOW THE SAME?
cout << endl << *(POINTER + 2); //WILL THIS SHOW THE CHARECTER PRESENT IN OBJECT.CHAR ?
}
If I write (POINTER+2) {technically it should mean the address of variable CHAR, because INT will take 2 bytes, so the third byte would be CHAR. But My Borland 5.02 compiler says "Illegal Structure Operation". All other statements work perfectly fine.