Answer the question
In order to leave comments, you need to log in
Is it possible to overload the postfix form of the ++ operator without using classes?
I want to overload the postfix form of the ++ operator for a variable of type string.
Tried like this:
string operator ++ (string s){
return s+"\n";
}
int main(){
string text = "text";
cout << ++text;
}
class S{
public:
string s;
S(string _s){
s = _s;
}
S operator ++ (int hz){
s += "\n";
return *this;
}
};
int main()
{
S n("text");
n++;
cout << n.s ;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question