Click here to Skip to main content
15,892,281 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
class child
{
int a,b;

}

int main()
{
child obj;
}
Posted
Comments
Richard MacCutchan 1-Oct-14 9:36am    
Any one you like. Re-read your course notes, or take a look at http://msdn.microsoft.com/en-us/library/3bstk3k5.aspx.

1 solution

C++ constructor is designed for this very purpose. See, for instance, this tutorial: "8.5 — Constructors"[^] (you should also read the next section, on destructors).
 
Share this answer
 
v2

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