Expanding on my comment, you can write your code using the PIMPL (pointer to implementation) idiom as follows:
In your header file (a.hpp)
class A
{
public:
A(int);
~A();
bool Eq(const A& a) const;
private:
class AImpl;
AImpl* implementation_;
};
In the implementation file (a.cpp)
struct A::AImpl {
AImpl(int x) : x_(x) {}
int x_;
};
A::A(int x)
: implementation_(new AImpl(x))
{}
A::~A()
{
delete implementation_;
}
bool
A::Eq(const A& rhs) const
{
return implementation_->x_ == rhs.implementation_->x_;
}
In your main file
#include "a.hpp"
int main()
{
A one(1);
A two(2);
return one.Eq(two);
}
Because all of the actual code is in the implementation file, you cannot see it from other classes (which will only include the header file a.hpp). For clarity, I used a raw pointer, but in a real setting you would want to use an appropriate smart pointer.