Passing object in c++ in a constructor

Revision en3, by Sumanto, 2020-09-10 08:53:08

My earlier code which was giving error: complete implementation here: https://ideone.com/MuOmlS

Code giving compilation error

This Code giving error as:

ERRORS

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

Correct code ( doubt is don't know why working correctly)

UPDATE:

After referring some blogs i came to know there is also an another way of handling this case

Different implemetation (correct)

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.

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en3 English Sumanto 2020-09-10 08:53:08 21
en2 English Sumanto 2020-09-10 08:46:08 704
en1 English Sumanto 2020-09-10 08:03:27 1719 Initial revision (published)