I see a lot of different conventions on the net when it comes to making
a class. Currently I make a class in a single .cc file like:
#include <string>
#include <iostream>
using namespace std;
class List {
private:
string name;
int id;
public:
// edit name
void setName(string newname);
// get name
string getName();
};
void List::setName(string str){
List::name = str;
}
string List::getName(){
return List::name;
}
int main(){
List mylist;
string newname = "Bo";
mylist.setName(newname);
string pp = mylist.getName();
cout << "sdfsdf \n" << pp << '\n';
return 0;
}
But is it better to leave implementation of the functions in another
file and keep the private/public sections in a .h file?