Hey guys can someone help me out?
My problem is that I don't know how to use templates with operators correctly.
This is my class:
template <typename T>
class myClass {
public:
myClass() {}
};
template <typename T>
//create copy of object T in myClass
myClass& operator<<(const T&) {
//how should my code look right here?
}
myClass& operator>>(T&){
//and here ??
}
And this is my main:
#include <iostream>
#include <string>
#include <fstream>
int main(){
myClass<string> e; // create empty myClass
string someText = "testing this text blabla";
e << someText; //input of someText in e
//test if input works correctly
string test;
e >> test; //put value of e in string test
cout << test << endl; //output test
return 0;
}