//This programm is for testing function overloading
#include <string>
#include <fstream>
#include <iostream>
using namespace std;
class Text
{
string str;
public:
Text ();
Text (string);
string contents ();
};
Text::Text (string st)
{
ifstream in (st);
getline (in, str);
}
string Text::contents ()
{
string ret;
ret=str;
return ret;
}
int main()
{
Text txt ("Sample.cpp");
string stg;
stg=txt.contents();
cout << "The output of the file is" << "\n" << stg;
}
agachhayat 0 Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.