Hi, I have a class that is fairly large and I would like to split the
file into two files, but still use only one class. What is the best way
to accomplish this?
Thanks!
A "fairly large" class may indicate that the class should be
redesigned, breaking it into smaller classes. However, you can declare
the class in a header file (say, MyClass.hpp) and then put the
implementation in two source files that both include the header (say,
MyClass1.cpp and MyClass2.cpp):
// In MyClass.hpp
class MyClass
{
void Foo();
void Bar();
};
// In MyClass1.cpp
#include "MyClass.hpp"
void MyClass::Foo()
{ /*...*/ }
// In MyClass2.cpp
#include "MyClass.hpp"
void MyClass::Bar()
{ /*...*/ }
Cheers! --M