I want to remove, if possible, the includes of both
If string and vector are used only in signatures of non-public members of you class, you could use the PImpl idiom:
// MyClass.h
class MyClassImpl;
class MyClass{
public:
MyClass();
void MyMethod();
private:
MyClassImpl* m_impl;
};
// MyClassImpl.h
#include
#include
#include
class MyClassImpl{
public:
MyClassImpl();
void MyMethod();
protected:
std::vector StdMethod();
};
// MyClass.cpp
#include
#include
void MyClass::MyMethod(){
m_impl->MyMethod();
}
You are always including vector and string in the header file, but only in the implementation part of your class; files including only MyClass.h will not be pulling in string and vector.