Thanks so far for all your help you have given me. My latest problem so far I can't seem to get my head around.
Basically I am making a program called "The DeathclocK" which is inspired by those Facebook apps that guess when you are going to die and by what means etc.
The program will be a menu driven console program and so far I have got all the main functions for the menu and a class which will hold information on the user.
However these errors are really frakkn me over and with my limited C++ knowledge I don't know whats going on.
int age; // ???? what is age?
int userage; // ???? what is userage
user newuser;
newuser.getage (userage); // ???
newuser.setage (userage,age); //???
You're trying to pass userage and age to functions before you set them to anything, meaning you'll get garbage. What exactly are you setting the age to?
Your errors are because your getage/setage functions are global. Meaning you never gave a body to your user::getage and user::setage functions.
You probably didn't mean to make those functions global:
int user::getage() // this makes more sense
Also your functions are a little misleading. I would expect 'getage' to simply return the age of the user. Not to do any i/o with the user. But whatever.
EDIT:
re: LittleQuick -- calling voids has nothing to do with anything. Also, main() must always return an int.
No, the problem are due to you not giving user::setage and user::getage functions a body. You need to give them a body. The constructor has nothing to do with it
class user //will store the attributes for the current player of the program
{
private:
int age;
int days;
int months;
int years;
public:
user::user ();
int user::getage ();
};
//constructor for user class
user::user ()
{
int age =0;
int days =0;
int months =0;
int years =0;
}
//destructor
//member functions
int getage (int userage, int age)
{
age = userage;
return age;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
// function declarations
void menu1(int);
void clearscreen();
void openuserlist ();
void start ();
void start ()
{
int age =0;
int userage=0;
cout << "Enter your age in years";
cin >> userage;
cout << endl;
user newuser;
newuser.getage ();
};
The errors are;
Error 1 error LNK2019: unresolved external symbol "public: int __thiscall user::getage(void)" (?getage@user@@QAEHXZ) referenced in function "void __cdecl start(void)" (?start@@YAXXZ) \\ad3\---------\Desktop\Assignment 3\Deathclock\Deathclock\dk_main.obj
You never seem to implement user::getage(). The only getage() I see is a function that doesn't seem to really do anything at line 30. Did you mean something else? :)