Apr 4, 2013 at 5:50am UTC
#include<iostream>
#include<conio.h>
using namespace std;
namespace ns{
class A{
public:
template<typename T>
void operator<< (T str){
cout<< str;
}
};
class B{
public:
template<typename S>
void operator>> (S &object){
cin>> object; }
template<>
void operator>> <string> (S &object){
getline(cin>> object);
};
A show;
B enter;
}
int main(){
using namespace ns;
string b;
enter>> b;
show<< b;
system("pause");
return(0);
}
This code is basically giving new names to objects cout and cin...
The error is generated at specializing the template at line 19 template<>...
Apr 4, 2013 at 8:11am UTC
I do not know where there is the line 19 because as all stupid guys you did not point out neither the line 19 nor the full error message. But in any case this statement
getline(cin>> object);
is invalid.