#ifndef INFORMATION_H
#define INFORMATION_H
#include <string>
using namespace std;
using std::string;
class Informations
{
public:
void setUsersName() ;
void setAge() ;
string getUsersName() ;
int getAge() ;
void PrintName() ;
void PrintAge() ;
private:
int x, age ;
string nameofuser ;
} ;
#endif // INFORMATION _H
Information.cpp
#include "Information.h"
#include <string>
#include <iostream>
using namespace std ;
class Informations{
public:
void setAge(){
cout << "What year were you born in?" << endl ;
cin >> x ;
age = 2012 - x ;
}
int getAge(){
return age ;
}
void PrintAge() {
cout << "You are " << age - 1 << "/" << age << " years old." << endl ;
}
void setUsersName(){
cout << "What is your name?" << endl ;
cin >> nameofuser ;
}
string getUsersName(){
return nameofuser ;
}
void PrintName(){
cout <<"Hello " << nameofuser << "." << endl ;
}
private:
string nameofuser ;
int x, age ;
} ;
but i get this error code
obj\Debug\main.o||In function `main':|
E:\C++ Programs\My First Program\main.cpp|13|undefined reference to `Informations::setUsersName()'|
E:\C++ Programs\My First Program\main.cpp|14|undefined reference to `Informations::PrintName()'|
E:\C++ Programs\My First Program\main.cpp|15|undefined reference to `Informations::setAge()'|
E:\C++ Programs\My First Program\main.cpp|16|undefined reference to `Informations::PrintAge()'|
||=== Build finished: 4 errors, 0 warnings ===|
You need to compile all the source files and link it all together. If you are using an IDE it often do this automatically if you make sure to put all the files in the same project.