Jun 25, 2013 at 6:59am UTC
#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();
}
Jun 25, 2013 at 7:18am UTC
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 Jun 25, 2013 at 7:19am UTC