Is there anything wrong with having a single class (one .h) implemented over multiple source files? I realize that this could be a symptom of too much code in a single class, but is there anything technically wrong with it?
For instance:
Foo.h
class Foo
{
void Read();
void Write();
void Run();
}
Foo.Read.cpp
#include "Foo.h"
void Foo::Read()
{
}
Foo.Write.cpp
#include "Foo.h"
void Foo::Write()
{
}
Foo.Run.cpp
#include "Foo.h"
void Foo::Run()
{
}
Each class shall have it's own header and implementation file. So if we wrote a class called MyString we would need an associated MyStringh. h and MyString.
Split the program into three files, main. c, which contains main(), node. h, the header which ensures declarations are common across all the program, and hence is understood by the compiler, and node. c, the functions which manipulate the NODE structure.
Multiple File Projects: Most of the time, full programs are not contained in a single file. Many small programs are easy to write in a single file, but larger programs involve separate files containing different modules. Usually, files are separated by related content.
This is fine. In the end, it will be all linked together.
I have even seen code, where every member function was in a different *.cpp file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With