samedi 26 juin 2021

Can anyone point out the error in my C++ program for constructor? [closed]

#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?? error

Aucun commentaire:

Enregistrer un commentaire