Hello everyone, i am getting a compilation error from the code below. It is when i am naming a variable with my user defined type. Can anyone hint me on how to correct the mistake.
void person :: displaydetails()
{
cout<<"First name is"<<FNAME<<endl;
cout<<"Surname is"<<SNAME<<endl;
cout<<"ID is"<<ID<<endl;
cout<<"Salary is "<<SALARY<<endl;
}
int main ()
{
person p[2];
person X("UJIji8j", "GILDARTS","JED",1234.5);
int i;
for (i=0;i<2;i++)
{
p[i].enterdetails();
}
for(i=0;i<2;i++)
{
p[i].displaydetails();
}
cout<<X.displaydetails();
cin.ignore();
system ("pause");
return EXIT_SUCCESS;
}
C:\Dev-Cpp\TRIAL.PASS.!!!.cpp In function `int main()':
66 C:\Dev-Cpp\TRIAL.PASS.!!!.cpp expected primary-expression before "p"
66 C:\Dev-Cpp\TRIAL.PASS.!!!.cpp expected `;' before "p"
74 C:\Dev-Cpp\TRIAL.PASS.!!!.cpp `p' undeclared (first use this function)
(Each undeclared identifier is reported only once for each function it appears in.)
83 C:\Dev-Cpp\TRIAL.PASS.!!!.cpp `X' undeclared (first use this function)
According you answer to my Q "default constructor", Didn't you said that
the compiler creates a default constructor by itself. so why it should not be compiled ?