hi
i almost have this code complete but i am getting 2 errors.
I am supposed to use function declared inside/outsie class
i almost have this code complete but i am getting 2 errors.
I am supposed to use function declared inside/outsie class
Code:
#include<iostream>
using namespace std;
#include<conio.h>
class person
{
char name[30];
int age;
public:
void getdata(void); //inside declaration
void display(void);
};
main()
{
person p; //object of type person
p.getdata();
p.display();
getche();
}
void person::getdata(void) //outside declaration
{
cout << "Enter name: ";
cin >> name;
cout << "Enter age: ";
cin >> age;
}
void person::display(void)
{
cout << "\nName: " << name;
cout << "\nAge: " << age;
}
Comment