Created
December 29, 2013 11:20
-
-
Save VitaminaCPP/8169424 to your computer and use it in GitHub Desktop.
Implementación de los operadores de Pre/Post-Incremento de una clase que opera sobre un dato integral
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class IntegerWrapper | |
{ | |
public: | |
// Operador de pre-incremento. | |
const IntegerWrapper &IntegerWrapper::operator++() | |
{ | |
mValor += 1; | |
return *this; | |
}; | |
// Operador de post-incremento. | |
const int IntegerWrapper::operator++(int) | |
{ | |
// Valor temporal necesario para la operacion. | |
int Temporal = mValor; | |
mValor += 1; | |
return Temporal; | |
} | |
private: | |
int mValor; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment