Re: Splitting up the definitions of a class into different files (splitting public from private)?

Discussion in 'C++' started by Mark, Jul 19, 2003.

  1. Mark

    Mark Guest

    Thanks guys! That's just what I needed...


    "Mark" <> wrote in message news:_vdSa.99451$H17.29351@sccrnsc02...
    Is it possible in C++ to somehow split the public and private class member definitions of a class such that the "public" .h file has just the public definitions?

    For example, something along these lines....

    In file MyClass.h:

    class MyClass {


    int getAttribute();

    and in file MyClass.cpp

    class MyClass {

    int _attribute;

    MyClass::MyClass() {}
    MyClass::~MyClass() {}

    int MyClass::getAttribute() { return _attribute; }

    I'm trying to find a way to hide away all the internal ("private:") stuff from anybody which includes MyClass.h, as well as to optimize compile times by not having modules which include MyClass.h have to compile other header files which are only required by the private members of a class.

    Mark, Jul 19, 2003
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.

Share This Page