I am new in programming in Cpp and I am doing a program with a class that must contains one name, the sex, the age and the phone number of the person.
I got three errors.
There is my program:
enter code here
#include <iostream>
#include <string>
#include <cstdlib>
using namespace std;
class infoPersonne
{
char *nom [40];
char *sexe;
int age;
char *notel [12];
public:
infoPersonne(char * , char *, int , char *);
infoPersonne();
infoPersonne(infoPersonne &ip);
~infoPersonne();
void affiche();
};
infoPersonne::infoPersonne(char *n, char *s, int a, char *nt) // contructeur
{
std::string nom=n;
std::string sexe=s;
age=a;
std::string notel=nt;
cout<< "construction de l'information d'une personne"<<endl;
}
infoPersonne::infoPersonne( infoPersonne &ip) // constructeur par recopie
{
std::string nom = ip.nom;
std::string sexe = ip.sexe;
age=ip.age;
std::string notel=ip.nt;
}
infoPersonne::infoPersonne() // constructeur par défaut
{
std::string nom = "";
std::string sexe = "";
age = 0;
std::string notel = "0";
}
infoPersonne:: ~infoPersonne() // destructeur
{
cout<<"destruction de l'information d'une personne"<<endl;
delete []nom;
delete sexe;
delete []notel;
}
void infoPersonne:: affiche()
{
cout << endl << "Nom :" << nom
<< endl << "Sexe :" << sexe
<< endl << "Age :" << age
<< endl << "Telephone : " << notel << endl;
}
using namespace std;
int main(int argc, char *argv[])
{
infoPersonne A();
infoPersonne B("Louise Messier","F",54, "514-756-8890");
A.affiche();
B.affiche();
system("PAUSE");
return EXIT_SUCCESS;
}
My first error appear on the line of the constructor by copy infoPersonne::infoPersonne(infoPersonne &ip) at the specific line std::string nom=ip.nom. ERROR IS : conversion from 'char* [40]' to non-scalar type 'std::string {aka std::basic_string}' requested| And I have another error: 'class infoPersonne' has no member named 'nt' but the member nt is defined? And the third one is : request for member 'affiche' in 'A', which is of non-class type 'infoPersonne()'|
Can you help me please ? Thank you in advance.