Inheritance

This is a discussion on Inheritance within the C++ Programming forums, part of the General Programming Boards category; I was wondering if there is a way to inherit from a class in a completely different cpp file? Any ...

  1. #1
    Registered User
    Join Date
    Jan 2002
    Posts
    1

    Unhappy Inheritance

    I was wondering if there is a way to inherit from a class in a completely different cpp file?

    Any help would be great!

  2. #2
    ¡Amo fútbol!
    Join Date
    Dec 2001
    Posts
    2,136
    Yep, you can. I forget the exact syntax of it, but I think you either have to declare extern before the class in the other cpp or do nothing. You definately should check the syntax because using multiple files is not my specialty. (aka: I suck at it )

  3. #3
    Registered User
    Join Date
    Dec 2001
    Posts
    421
    classA.h:

    class A
    {
    }

    classA.cpp:

    A::A(void)
    {}

    classB.h:

    #include "classA.h"
    class B : public A
    {
    }


    hope this helps!
    U.
    Quidquid latine dictum sit, altum sonatur.
    Whatever is said in Latin sounds profound.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 16
    Last Post: 06-08-2009, 04:03 PM
  2. Virtual inheritance
    By 6tr6tr in forum C++ Programming
    Replies: 13
    Last Post: 05-07-2008, 12:20 PM
  3. Multiple Inheritance - Size of Classes?
    By Zeusbwr in forum C++ Programming
    Replies: 10
    Last Post: 11-26-2004, 09:04 AM
  4. inheritance and performance
    By kuhnmi in forum C++ Programming
    Replies: 5
    Last Post: 08-04-2004, 01:46 PM
  5. Inheritance vs Composition
    By Panopticon in forum C++ Programming
    Replies: 11
    Last Post: 01-20-2003, 04:41 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21