• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 170
  • Last Modified:

Compiling

When you write a program that uses a base class that has derived classes, do you declare the base class and the derived classes separatelly in different .h files, and then do you implement them in different .cpp files, or you declare the base class and the derived ones within one single .h file and implement the base class and the derived ones in one .cpp file ?
Can you chose how to do that also by the size or number of derived classes , or is it a good programming style to go allways one way ?
0
simi
Asked:
simi
1 Solution
 
mpewjgCommented:
I normally put them together, but it also OK to put in different .h file once you #include the base when use it.
For implementation, even the member functions in one class can be implemented in different .cpp files. of course you much include the .h file and have "CClassName ::" before each member functions. This is useful when your class have too much functions and one .cpp file become too huge to manage it.
That means you must change the style according to th situation and try to keep all files to be managed easily.
0
 
simiAuthor Commented:
Thanks
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now