Skip to main content
added 2 characters in body
Source Link
Aan
  • 13k
  • 36
  • 93
  • 151

I am trying to deal with operator overloading at the first time, and I wrote this code to overload ++ operator to increment class variables i and x by one.. It dodoes the job but the compiler showed these warnings:

Warning 1 warning C4620: no postfix form of 'operator ++' found for type 'tclass', using prefix form c:\users\ahmed\desktop\cppq\cppq\cppq.cpp 25

Warning 2 warning C4620: no postfix form of 'operator ++' found for type 'tclass', using prefix form c:\users\ahmed\desktop\cppq\cppq\cppq.cpp 26

This is my code:

class tclass{ public: int i,x; tclass(int dd,int d){ i=dd; x=d; } tclass operator++(){ i++; x++; return *this; } }; int main() { tclass rr(3,3); rr++; rr++; cout<<rr.x<<" "<<rr.i<<endl; system("pause"); return 0; } 

I am trying to deal with operator overloading at the first time, and I wrote this code to overload ++ operator to increment class variables i and x by one.. It do the job but the compiler showed these warnings:

Warning 1 warning C4620: no postfix form of 'operator ++' found for type 'tclass', using prefix form c:\users\ahmed\desktop\cppq\cppq\cppq.cpp 25

Warning 2 warning C4620: no postfix form of 'operator ++' found for type 'tclass', using prefix form c:\users\ahmed\desktop\cppq\cppq\cppq.cpp 26

This is my code:

class tclass{ public: int i,x; tclass(int dd,int d){ i=dd; x=d; } tclass operator++(){ i++; x++; return *this; } }; int main() { tclass rr(3,3); rr++; rr++; cout<<rr.x<<" "<<rr.i<<endl; system("pause"); return 0; } 

I am trying to deal with operator overloading at the first time, and I wrote this code to overload ++ operator to increment class variables i and x by one.. It does the job but the compiler showed these warnings:

Warning 1 warning C4620: no postfix form of 'operator ++' found for type 'tclass', using prefix form c:\users\ahmed\desktop\cppq\cppq\cppq.cpp 25

Warning 2 warning C4620: no postfix form of 'operator ++' found for type 'tclass', using prefix form c:\users\ahmed\desktop\cppq\cppq\cppq.cpp 26

This is my code:

class tclass{ public: int i,x; tclass(int dd,int d){ i=dd; x=d; } tclass operator++(){ i++; x++; return *this; } }; int main() { tclass rr(3,3); rr++; rr++; cout<<rr.x<<" "<<rr.i<<endl; system("pause"); return 0; } 
added 35 characters in body
Source Link
Shahbaz
  • 47.8k
  • 19
  • 120
  • 187

I am trying to deal with operator overloading at the first time, and I wrote this code to overload ++ operator to increment class variables i and x by one.. It do the job but the compiler showed these warnings:

Warning 1 warning C4620: no postfix form of 'operator ++' found for type 'tclass', using prefix form c:\users\ahmed\desktop\cppq\cppq\cppq.cpp 25

Warning 2 warning C4620: no postfix form of 'operator ++' found for type 'tclass', using prefix form c:\users\ahmed\desktop\cppq\cppq\cppq.cpp 26

This is my code:

class tclass{ public: int i,x; tclass(int dd,int d){ i=dd; x=d; }  tclass operator++(){   i++;   x++;   return *this;  } }; int main() { tclass rr(3,3); rr++; rr++; cout<<rr.x<<" "<<rr.i<<endl; system("pause"); return 0; } 

I am trying to deal with operator overloading at the first time, and I wrote this code to overload ++ operator to increment class variables i and x by one.. It do the job but the compiler showed these warnings:

Warning 1 warning C4620: no postfix form of 'operator ++' found for type 'tclass', using prefix form c:\users\ahmed\desktop\cppq\cppq\cppq.cpp 25

Warning 2 warning C4620: no postfix form of 'operator ++' found for type 'tclass', using prefix form c:\users\ahmed\desktop\cppq\cppq\cppq.cpp 26

This is my code:

class tclass{ public: int i,x; tclass(int dd,int d){ i=dd; x=d; } tclass operator++(){ i++; x++; return *this; } }; int main() { tclass rr(3,3); rr++; rr++; cout<<rr.x<<" "<<rr.i<<endl; system("pause"); return 0; } 

I am trying to deal with operator overloading at the first time, and I wrote this code to overload ++ operator to increment class variables i and x by one.. It do the job but the compiler showed these warnings:

Warning 1 warning C4620: no postfix form of 'operator ++' found for type 'tclass', using prefix form c:\users\ahmed\desktop\cppq\cppq\cppq.cpp 25

Warning 2 warning C4620: no postfix form of 'operator ++' found for type 'tclass', using prefix form c:\users\ahmed\desktop\cppq\cppq\cppq.cpp 26

This is my code:

class tclass{ public: int i,x; tclass(int dd,int d){ i=dd; x=d; }  tclass operator++(){   i++;   x++;   return *this;  } }; int main() { tclass rr(3,3); rr++; rr++; cout<<rr.x<<" "<<rr.i<<endl; system("pause"); return 0; } 
Source Link
Aan
  • 13k
  • 36
  • 93
  • 151

Overload ++ operator

I am trying to deal with operator overloading at the first time, and I wrote this code to overload ++ operator to increment class variables i and x by one.. It do the job but the compiler showed these warnings:

Warning 1 warning C4620: no postfix form of 'operator ++' found for type 'tclass', using prefix form c:\users\ahmed\desktop\cppq\cppq\cppq.cpp 25

Warning 2 warning C4620: no postfix form of 'operator ++' found for type 'tclass', using prefix form c:\users\ahmed\desktop\cppq\cppq\cppq.cpp 26

This is my code:

class tclass{ public: int i,x; tclass(int dd,int d){ i=dd; x=d; } tclass operator++(){ i++; x++; return *this; } }; int main() { tclass rr(3,3); rr++; rr++; cout<<rr.x<<" "<<rr.i<<endl; system("pause"); return 0; }