Need help with this rogram, giving error in constructor

#include<iostream.h>
#include<fstream.h>
#include<cstdlib>
#include<cstring>
ofstream re;
class studentinfo
{
private:
char* VUID;
char* campusID;
char* Studentname;
char* Fathername;

public:
void Storefile(char*, char*, char*, char*);
char Display() ;
studentinfo(char*, char*, char*, char*);
~studentinfo();
};
studentinfo::studentinfo(char* VUID, char* campusID, char* Studentname, char* Fathername)
{
VUID = "mc123456789";
campusID = "dfrgt80";
Studentname = "kgk glkh kjhlk";
Fathername = "kjhklh kljhlkjh kjhlkjh";
cout<<"Contructor Called"<<endl;
}
studentinfo::~studentinfo()
{
cout<<"Destructor Called for destruction of the object"<<endl;
}
void studentinfo::Storefile(char* VUID, char* campusID, char* Studentname, char* Fathername)
{
char* ID;
char* camID;
char* stdntnme;
char* Fthrnme;
re.open("record.txt");
if(!re)
{
cout<<"Error Reading File"<<endl;
}
re<<ID<<endl<<camID<<endl<<stdntnme<<endl<<Fthrnme<<endl;
re.close();
}

char studentinfo::Display()
{
char* VUID;
char* campusID;
char* Studentname;
char* Fathername;
ifstream re;
re.open("record.txt");
if(!re)
{
cout<<"Error Reading File"<<endl;
}
re>>VUID>>campusID>>Studentname>>Fathername;
cout<<VUID<<endl<<campusID<<endl<<Studentname<<endl<<Fathername<<endl;
re.close();
}



main()
{
studentinfo s1;
std1.Storefile(&VUID, &campusID, &Studentname, &Fathername);
std1.Display();

}
In main() you're creating s1 without passing any argument, which means studentInfo() should be called.
You declared only a ctor that takes four char*, and the compiler creates a default ctor only if there isn't one explicitly declared, therefore studentInfo() doesn't exist.

Also please enclose source code in code tags. It preserves indentation and makes the code more readable.
Last edited on
Topic archived. No new replies allowed.