#include <iostream>
using namespace std;
class person
{
long id;
char name[30];
char gender;
float income;
public:
person();
person(long,char[],char,float);
void display()
{
std::cout << id << name <<gender <<income << '\n';
}
};
person::person()
{
id=0;
strcp(name,"NOT KEYED");
gender='';
income=0;
}
person::person(long uid,char n[],char g,float inc)
{
id=uid;
strcp(name,n);
gender=g;
income=inc;
}
int main() {
person p1;
std::cout << "Objectdetails" << '\n';
p1.display();
return 0;
}
I have created a class here and within the class i have declared two constructor first one is default constructor and second oone is parameterised constructor .I have perfectly written the code but i am encounteriong with errors here which i am unable to understand can anybody help me??
Aucun commentaire:
Enregistrer un commentaire