Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple classes in one .cpp file

Tags:

c++

I was wondering if it is considered bad practice to have multiple classes in one .cpp file. I have a background in Objective-C, where this is rarely done.

like image 275
seanlth Avatar asked Sep 03 '12 19:09

seanlth


1 Answers

It makes for less readable code because you usually expect a class's definition to be in the header with the same name and the implementation in an implementation file with the same name.

There are cases in practice where a class is relatively small and closely-related small classes can be grouped together, but it's on a case-by-case basis.

like image 171
Luchian Grigore Avatar answered Sep 24 '22 22:09

Luchian Grigore