I compiled and executed above program ...and its working absolutely fine...
I chose data memmber of student class as pointeer to the object of the same class(student*s;) and its working fine...How can this be possible?
How can I create the instance of a class as a data member of the same class.
Lets say when I am creating first object of this class(Student s1;)and then
when control goes through this statement(student*s;) it doesnt even have slightest idea of how much space this object will consume as it didnt constrct any object so far..Like that when I assume its going to infinite loop..I dont know what I think is right but it doesnt make even slightest sense to me.
Please let me know if we can have a clss have data memeber as the object of the same class?
Please let me know if below code is possible
using namespace std;
student s; //I chose object itself as data memmber not pointer