#include typedef long long integer; class Fraction { private: integer numerator = 0; // esto es tambien es inicializacion a partir de C++11 integer denominator = 1; public: Fraction(integer numerator = 0, integer denominator = 1) : numerator{numerator} // esto SI es inicializacion en C++ , denominator{denominator ? denominator : 1} { //numerator = 0; // Esto NO es inicializacion //denominator = 1; // es asignacion } inline integer getNumerator() const { return this->numerator; } inline void setNumerator(integer numerator) { Fraction::numerator = numerator; } inline integer getDenominator() const { return this->denominator; } inline void setDenominator(integer denominator) { if ( denominator ) this->denominator = denominator; } void print() const { std::cout << this->getNumerator() << '/' << this->denominator; } }; // Funcion libre int main() { Fraction fr1; fr1.setDenominator(-3); fr1.setDenominator(0); std::cout << "fr1 = "; fr1.print(); std::cout << std::endl; Fraction fr2(2, 9); std::cout << "fr2 = "; fr2.print(); std::cout << std::endl; Fraction fr3(5); std::cout << "fr3 = "; fr3.print(); std::cout << std::endl; Fraction* fr0 = new Fraction(); delete fr0; }