I am putting my declaration and implementation of "private classes" (only the containing cpp files can instantiate it) in my the cpp files like below
//in my header file
class MyMainClass
{
public:
int someStuff();
private:
};
//in my cpp file
class MyPrivateClass
{
public:
int getSomeStuff()
{
int the_result = // do some stuff and return the result
return the_result;
}
};
int MyMainClass::someStuff()
{
MyPrivateClass p;
return p.getSomeStuff() + 5;
}
//in my header file
class MyMainClass
{
public:
int someStuff();
private:
};
//in my cpp file
class MyPrivateClass
{
public:
int getSomeStuff()
{
int the_result = // do some stuff and return the result
return the_result;
}
};
int MyMainClass::someStuff()
{
MyPrivateClass p;
return p.getSomeStuff() + 5;
}
To copy to clipboard, switch view to plain text mode
is this considered bad practice? as alleged by some of my co-worker.
My reasoning behind doing this is that i don't want to share my "MyPrivateClass" so i did not create a header and cpp file for it. My concern is that they might start using my "MyPrivateClass" which is not designed to be shared if i will create another files for it.
Bookmarks