Linked Questions

2493 votes
10 answers
1.1m views

Note: The answers were given in a specific order, and have received varying amounts of votes over time. Since the order of answers depends on your answer sorting preferences, here's an index of the ...
sbi's user avatar
  • 225k
-5 votes
1 answer
665 views

I've got this code, but I do not understand the output... class Complex { private: float re; float im; public: Complex(float r = 0.0, float i = 0.0) : re(r), im(i){}; ...
Bozidar Vulicevic's user avatar
0 votes
0 answers
42 views

I was trying to overload operators in my template class, but compilator show error: Error C2676 binary '++': 'Iterator' does not define this operator or a conversion to a type acceptable to the ...
Darek's user avatar
  • 31
925 votes
15 answers
107k views

#include <stdio.h> int main(void) { int i = 0; i = i++ + ++i; printf("%d\n", i); // 3 i = 1; i = (i++); printf("%d\n", i); // 2 Should be 1, no ? volatile int u = 0; u ...
PiX's user avatar
  • 9,925
24 votes
3 answers
27k views

I'm wanting to make sure I understand pass-by-value vs pass-by-reference properly. In particular, I'm looking at the prefix/postfix versions of the increment ++ operator for an object. Let's suppose ...
Cam's user avatar
  • 15.3k
24 votes
6 answers
13k views

Have a look at these function signatures: class Number { public: Number& operator++ (); // prefix ++ Number operator++ (int); // postfix ++ }; Prefix doesn't take any parameter but ...
Naruto's user avatar
  • 9,654
10 votes
5 answers
12k views

Can I use: MyClass& MyClass::operator++ () { a++; // private var of MyClass return (*this); } Or it can be: MyClass MyClass::operator++ (); What's the difference? Thanks for answers. I ...
name3r123's user avatar
  • 163
2 votes
5 answers
771 views

I saw this C++ code as part of a larger example: Date &Date::operator++() { helpIncrement(); return *this; } Date Date::operator++( int ) { Date temp = *this; helpIncrement(); ...
user997112's user avatar
  • 31.1k
3 votes
1 answer
4k views

I am writing my own array class as an exercise. Since, I read non-member functions are actually better in some ways than member functions. (Scott Meyers) I am trying to write as many operator ...
thassan's user avatar
  • 401
0 votes
2 answers
576 views

I have one doubt on prefix operator overloading . my sample program: class ABC { int i; public: const ABC& operator++() { i=i+1; return *this;} }; int main() { ABC ob ; //let value ...
rajiba pradhan's user avatar
0 votes
2 answers
155 views

I am having difficulty figuring out how to overload the postfix increment operator for an nested enumerated type of class Card. Moreover, I am also having difficulty getting copy assignment to work ...
Eric_Hondzinski's user avatar
1 vote
2 answers
112 views

What's the difference between the following two assignments? #include<iostream> using namespace std; int main(){ int a=10,i=0; ++i = a //COMPILES WITHOUT ERROR i++ = a //GIVES AN ...
DEVESH JHA's user avatar
-1 votes
1 answer
326 views

Error message: class.cpp: In function 'RationalNumber operator++(const RationalNumber&, int)': class.cpp:27:28: error: assignment of member 'RationalNumber::numerator' in read-only object r....
jaxk's user avatar
  • 7