My earlier code which was giving error: complete implementation here: https://ideone.com/MuOmlS
This Code giving error as:
correct code after referring this thread https://stackoverflow.com/questions/12466055/field-has-incomplete-type-error/12466219 i implemented and it worked but from this thread i couldn't able to understand why pointer object is doing which leads to removal of error?
complete implementation here: https://ideone.com/SSVnOU
UPDATE:
After referring some blogs i came to know there is also an another way of handling this case
I Believe i am missing some concept of c++ language which i need to know to understand what's going on here. Please share your views regarding this.
The StackOverflow page you referred to had the answer. I'll just reiterate what was written there:
When you do forward declaration i.e only declare but not define, then the compiler just knows it'll exist, its definition is provided on link time. Now why it affects the way it did here: The compiler doesn't know the size of the object to allocate, since it's not defined, so we can only use a pointer which is always going to be the size of a memory address(4 bytes usually). We actually do this (forward declaration then using a pointer) in PIpml idiom too, if you've done that you can relate from there as well.
Hope it helps.
P.S: I'm not a Cpp expert(unlike my name suggests) so I might have said something wrong, but I think I explained the main question.