Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Compiling

Posted on 1998-03-10
2
Medium Priority
?
169 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 

Accepted Solution

by:
mpewjg earned 80 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
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.

650 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