Why it does not compile?

C

Constant

#include <iostream.h>
#include <string>
#define BUFSIZE 128 /*Constant using macro –no checking type*/

using namespace std; /*standard container class*/

class person{
public: /*Default constructor */
char *surname, *givename, *address, *birthday; /*also another
solution by switching completely to initializer lists, using
std::string instead of char*,using namespace std.*/
person(); /*definiton of person*/
person(char *sn, char *gn, char *addr, char *bDay){
surname=sn;
givename=gn;
address=addr;
birthday=bDay;
}
/*show new name*/
void nameChange(char *sname, char *gname){
surname=sname;
givename=gname;
cout<<"Name has been changed"<<endl;
}
/*show new address*/
void addrChange(char *addr){
address=addr;
cout<<"Address has been changed"<<endl;
}
/*show surname and givename*/
void showName(){
cout<<"Surname: "<<surname<<endl;
cout<<"Givename: "<<givename<<endl;
}
/*show addres*/
void showAddr(){ /*show addres*/
cout<<"Address: "<<address<<endl;
}
person(){}; /*recalls the properties of person*/
};
/*Student inherits form person*/
class student:public person{
private:

int studentNo; /*define student number as int*/
/*Student contructor*/
public:

student(char *sn, char *gn, char *addr, char *bDay, int sNo) /*also
changes to the construcotr stundent(const string &,const string
&,const string &,const string &,const int&);*/
:person(sn,gn,addr,bDay){
studentNo=sNo;
}
void showStudentNo(){
cout<<"Sudent No: "<<studentNo<<endl; /*also here could have been
optimised std::cout << "Student No: " << studentNo << std::endl:*/
}
};

int main(){

cout<<"----------person----------"<<endl;
person p1=person("Fausto", "Rstom", "YO-KYLA 2D 29", "06.02.73");
p1.showName();
p1.nameChange("Fausto","Rstom");
cout<<"Show name agian!"<<endl;
p1.showName();
cout<<"Show address!"<<endl;
p1.showAddr();

cout<<"---------student------------"<<endl;
student s1=student("Gherici", "Constantin", "Nostovaenkatu 20 as 13",
"21.05.73", 12345);
s1.showName();
s1.showStudentNo();
s1.showAddr();
s1.addrChange("Yo-kyla 10A 23");
cout<<"Show address agian!"<<endl;
s1.showAddr();
return 0;
}
 
S

Sharad Kala

Constant said:
#include <iostream.h>
#include <string>
#define BUFSIZE 128 /*Constant using macro -no checking type*/

using namespace std; /*standard container class*/

class person{
public: /*Default constructor */
char *surname, *givename, *address, *birthday; /*also another
solution by switching completely to initializer lists, using
std::string instead of char*,using namespace std.*/
Remove the above line. You are providing the constructor definition later within
the body of class.
btw, this is a declaration and not a definition.

-Sharad
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,021
Latest member
AkilahJaim

Latest Threads

Top