On compilation it gives:Code:// streams.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include <iostream> #include <fstream> #include<conio.h> using namespace std; class Student { private: int number; char name[50]; float gpa; public: Student (int n,const char *s, float g); void save(ofstream& of); void load(ifstream& inf); }; int main() { Student me(11321, "Myself", 4.3); ofstream myfile; ifstream myf; myfile.open("silly.txt"); me.load(myf); me.save(myfile); myfile.close(); getch(); return 0; } void Student::save(ofstream& of) { of.write((char*)&number, sizeof(number)); of.write((char*)name, sizeof(name)); of.write((char*)&gpa, sizeof(gpa)); } void Student::load(ifstream& inf) { inf.read((char*)&number, sizeof(number)); inf.read((char*)name, sizeof(name)); inf.read((char*)&gpa, sizeof(gpa)); }
1>streams.obj : error LNK2019: unresolved external symbol "public: __thiscall Student::Student(int,char const *,float)" (??0Student@@QAE@HPBDM@Z) referenced in function _main
1>c:\users\javed\documents\visual studio 2010\Projects\streams\Debug\streams.exe : fatal error LNK1120: 1 unresolved externals
Although i followed what is suggested here: