Which class to use? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Which class to use?

Is it best to use internal classes in the same .cpp file as the main, or an external class in a separate .cpp and .h file? Better question; what are the disadvantage and advantages to each? Additionally, what is a struct, and when should they be used? I heard they're fairy similar. Many thanks!

24th Jul 2016, 8:28 PM
Cohen Creber
Cohen Creber - avatar
3 Answers
+ 4
better use separate files. it's helping when compiling big project ( multithread compilation, recompilation only of changed translation units, etc.) structure used when you combining c and c++ code. or writing small type that no need of inheritance and function virtualization.
25th Jul 2016, 11:54 AM
Владимир Косков
Владимир Косков - avatar
0
Thank you! :)
25th Jul 2016, 1:45 PM
Cohen Creber
Cohen Creber - avatar
- 3
gugg
25th Jul 2016, 11:39 AM
Sundar Babu
Sundar Babu - avatar