Why doesn't my code work?
Hi everyone! I created this code and separated the header & the source file, but it doesn't work. Take a look: main.cpp: ------------------------------------------- #include <iostream> #include <string> #include "person.h" using namespace std; int main() { person John; John.print_name("John"); John.print_age(61); John.print_birthplace("England"); John.set_NSN(136); John.print_NSN(); return 0; } ------------------------------------------------------ person.h: ---------------------------------------------------- #ifndef PERSON_H #define PERSON_H class person { public: person(); void print_name(string name); void print_age(int age); void print_birthplace(string birthplace); void set_NSN(int x); void print_NSN(); protected: private: int NSN; }; #endif // PERSON_H --------------------------------------------- person.cpp: --------------------------------------------- #include "person.h" person::person() { cout<<"person:\n"; } void person::print_name(string name="John") { cout<<name<<endl; } void person::print_age(int age=66) { cout<<age<<endl; } void person::print_birthplace(string birthplace="England") { cout<<birthplace<<endl; } void person::set_NSN(int x=136) { NSN=x; } void person::print_NSN() { cout<<NSN; }