I have been working a lot with Java, and C++ is right down confusing.
In Java you have class files, at first I supposed it's the equivalent to header files in C++, like so:
#ifndef PROGRAM_H
#define PROGRAM_H
#include <iostream>
#include <string>
class Program {
private:
std::string name, version, author;
public:
Program(std::string name, std::string version, std::string author) {
this->name = name;
this->version = version;
this->author = author;
}
std::string toString() {
return name + " " + version + " - by " + author + "\n";
}
} MainProgram("program", "2.0a", "foo bar");
#endif
I've just read that I should separate my classes into two files, the header to define the class, and the .cpp to implement the class.
Should I really do it to each class? because the header class above compiles just fine, and it seems too simple to really separate it to two files, perhaps maybe only large classes should be separated by convention? Any suggestions?