C++ - Distributing different headers than development
- by Ben
I was curious about doing this in C++:
Lets say I have a small library that I distribute to my users. I give my clients both the binary and the associated header files that they need. For example, lets assume the following header is used in development:
#include <string>
ClassA
{
public:
bool setString(const std::string & str);
private:
std::string str;
};
Now for my question. For deployment, is there anything fundamentally wrong with me giving a 'reduced' header to my clients? For example, could I strip off the private section and simply give them this:
#include <string>
ClassA
{
public:
bool setString(const std::string & str);
};
My gut instinct says "yes, this is possible, but there are gotchas", so that is why I am asking this question here. If this is possible and also safe, it looks like a great way to hide private variables, and thus even avoid forward declaration in some cases.
I am aware that the symbols will still be there in the binary itself, and that this is just a visibility thing at the source code level.
Thanks!