a simple program


Hello. I am trying to make my first program wich contains a class and my code is not working. Can you please give me a hint because i cannot see where i am wrong please. Thank you.




#include <iostream>
using namespace std;

class MyClass {

public:
void Age()
{
int a,b,answer;
cout <<"insert the birth year in format yyyy "<<endl;
cin >>b;
a=2012;
answer = a-b;
cout<<"the answer is"<<answer<<endl;
}

}

int main()
{
MyClass Object;
Obiect.Age();

return 0;


}
you have not declared and defined constructor and destructor .
one suggestion :- use Class instance name any other name then Object .
No constructor/destructor needed here.
But:
Object <-> Obiect
Thank you but my big problem was ";" after the class ending wich i forgot
Topic archived. No new replies allowed.