Solved

Compiling

Posted on 1998-03-10
2
163 Views
Last Modified: 2010-04-10
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
Comment
Question by:simi
2 Comments
 

Accepted Solution

by:
mpewjg earned 20 total points
ID: 1183329
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
 

Author Comment

by:simi
ID: 1183330
Thanks
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

815 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now