By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,389 Members | 1,881 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,389 IT Pros & Developers. It's quick & easy.

Any sub-classes in C++?

P: 79
In Java, we can sub-divide a class into multiple smaller classes to distribute responsibilities. How can we solve the same problem in MSVC++ ?
Mar 19 '07 #1
Share this Question
Share on Google+
1 Reply


Ganon11
Expert 2.5K+
P: 3,652
I assume you are talking about inheritance. In Java, you would write:

Expand|Select|Wrap|Line Numbers
  1. public class SuperClass {
  2.    // ...class definition here...
  3. }
  4.  
  5. public class SubClass1 extends SuperClass {
  6.    // ...class definition here...
  7. }
  8.  
  9. public class SubClass2 extends SuperClass {
  10.    // ...class definition here...
  11. }
In C++ you would write:

Expand|Select|Wrap|Line Numbers
  1. class SuperClass {
  2.    // ...class def. here...
  3. };
  4.  
  5. class SubClass1: public SuperClass {
  6.    // ...class def. here...
  7. };
  8.  
  9. class SubClass2: public SuperClass {
  10.    // ...class def. here...
  11. };
Mar 19 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.