I'm wondering to code a C++ application with a header-only layout like the following:
// code3.h
#include <iostream>
class code3
{
public:
void print()
{
std::cout << "hello " << std::endl;
}
};
// code2.h
#include "code3.h"
class code2
{
public:
void print()
{
code3 c;
c.print();
}
};
// code1.h
#include "code3.h"
class code1
{
public:
void print()
{
code3 c;
c.print();
}
};
// main.cpp
#include "code1.h"
#include "code2.h"
int main()
{
code1 c1;
c1.print();
code2 c2;
c2.print();
}
The only cpp file will be the main file. The rest of the code will be placed in header files.
I would like to know if there is some kind of performance problem with this approach. I know that defining the methods in the class declarations inlines them, but as it will be only one cpp file, the inline methods won't be duplicated. I just want to focus my question on the performance. I'm not talking about extensibility, legibility, maintenance or anything else. I want to know if I'm missing something with this approach that could generate a performance problem.
Thanks!