Solved

Compiling

Posted on 1998-03-10
2
161 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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

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…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
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.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

758 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

16 Experts available now in Live!

Get 1:1 Help Now