Hi all,
Need your help. I am doing a simple template program , getting some error ... here is the code
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include<iostream>
#include<string>
#include <sstream>
using namespace std;
class Base_class
{
public:
Base_class(){ };
~Base_class(){ };
template <class T>
static int fun(T decimal_value,string& check)
{
ostringstream ostr;
ostr<<decimal_value<<endl;
string str=ostr.str();
check=str;
return 0;
}
};
int main()
{
try
{
string check;
int a=7777;
Base_class ::fun(a,check);
cout<<check<<endl;
double b=7777.9755;
Base_class::fun(b,check);
cout<<check<<endl;
char c[]="AMARTYA";
Base_class::fun(c,check);
cout<<check<<endl;
}
catch(...)
{
cout<<"Function Cutil::failed"<<endl;
}
return 0;
}
This code works fine ....
But i want the Definition of the function not in the main class , i want to put it outside function ......
If i do that ..... It is giving error .....
Please provide some solution(s)...