Click here to Skip to main content
15,940,173 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
can we use the name of the class instead of its object in the following syntax :
student s;*)&s,sizeof(s));

where s is the object of the class.
and student is the mane of the class

What I have tried:

Basically nothing,
Updated 4-Feb-18 23:39pm
Jochen Arndt 5-Feb-18 6:01am    
You already got an answer to your question but you should be careful when reading and writing class contents as they are. That won't work if your class contains dynamic objects (pointers to allocated objects).
Richard MacCutchan 5-Feb-18 7:45am    
Why not just try it, ans see what results you get?

1 solution

Yes you can.
The compiler happily accetps
As you may easily verify.

The form
however is more robust (if you change the type of s it remains correct).
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900