Login or Sign Up
Logging in...
Remember me
Log in
Or
Sign Up
Forgot password or user name?
Log in with
Search in titles only
Search in C only
Search
Advanced Search
Forums
Product Launch
Updates
Today's Posts
Member List
Calendar
Home
Forum
Topic
C
How to overlaod ++ operator for a object having 2 data members?
Collapse
X
Collapse
Posts
Latest Activity
Photos
Page
of
1
Filter
Time
All Time
Today
Last Week
Last Month
Show
All
Discussions only
Photos only
Videos only
Links only
Polls only
Events only
Filtered by:
Clear All
new posts
Previous
template
Next
sam142
New Member
Join Date:
Jun 2012
Posts:
5
#1
How to overlaod ++ operator for a object having 2 data members?
Jun 26 '12, 07:35 PM
how to increment both data members and display both member data separately.
weaknessforcats
Recognized Expert
Expert
Join Date:
Mar 2007
Posts:
9214
#2
Jun 27 '12, 01:19 AM
What's the problem?
operator++ determines how to increment your object. The overload as a phony int argument for postfix and none for prefix. It makes no difference how many member variables need to change.
Code:
MClass& MyClass::operator++(int) { this->member1++; this->member2++; return *this; }
Comment
Post
Cancel
Previous
template
Next
Working...
Yes
No
OK
OK
Cancel
👍
👎
☕
Comment