Declare a structure in a class | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Declare a structure in a class

How can I declare a structure in an implementation of a function in a class??

10th Mar 2017, 8:15 AM
AREZOO
1 Answer
0
you would create the struct outside of the class. then declare an object of that struct as a member of the class struct mstruct {...} class mclass { private: int num; mstruct obj; ...} you could create an array of them as well. you could also just make the struct a class lol. that would be called aggregation, such that one class is made up of other classes. hope this helps
11th Mar 2017, 2:18 AM
Michael Szczepanski
Michael Szczepanski - avatar