Wrong. All wrong. The fact is that when we do this
Someclass obj;
then we construct an instance of the object. At the same time, it is created on the stack or in global memory and the sizeof (Someclass) memory is allocated for it.
If we do this:
Someclass * obj;
then we create a pointer. There is no fundamental difference from void* obj
, except that the compiler will check how we will use this pointer and will not allow us to implement absolutely obviously delusional options. But still, he can be explained to him to shut up, if it is really necessary. The size of the pointer depends on the type of platform for which we build the program. But we can assume that it is 4 or 8 bytes. At the same time, a pointer is essentially an address in memory. No more and no less. As long as we have not tied this pointer to the object, we will not be able to apply to any fields, and we cannot call any f-tions either.
Those.
Someclass *obj; obj->somefunc(); // сразу вызовет падение программы
Usually it uses pointers like this:
Someclass obj; Someclass *pointer; pointer = &obj; pointer->somefunc(); // OK Someclass *pointer2 = new Someclass; // объявили указатель и сразу создали объект, а затем записали его адрес в указатель. pointer2->somefunc(); // тоже OK