\CPP\Advanced
Template_Class.cpp
#include#include #include #include template class CSample { private: T One; public: int WriteOut(); int ReadIn(); void SetVarOne(T Data); void PrintValue(); }; template void CSample ::SetVarOne(T Data) { this->One = Data; } template void CSample ::PrintValue() { cout << One; } template int CSample ::WriteOut() { ofstream fOut; fOut.open("Temp.txt", ios::binary); if(fOut.fail()) return 1; fOut << this->One; fOut.close(); return 0; } template int CSample ::ReadIn() { ifstream fIn; T Buffer; fIn.open("Temp.txt", ios::binary); if(fIn.fail()) { this->One = 0; return 1; } fIn >> Buffer; fIn.close(); this->One = (T)Buffer; return 0; } int main() { CSample Sample; CSample Sample1; // Simple Sample Sample.SetVarOne(5); cout << "Value Set:"; Sample.PrintValue(); cout <