# include <iostream>
#endif
-Ascii::Ascii(char c = '0'): caracter(c) {
+Ascii::Ascii(char c): caracter(c) {
#ifdef DEBUG
std::cerr << "En constructor de Ascii." << std::endl;
#endif
return caracter == ascii.caracter;
}
-short Ascii::operator short(void) {
+Ascii::operator char(void) const {
+#ifdef DEBUG
+ std::cerr << "En cast de Ascii a char." << std::endl;
+#endif
+ return static_cast<char>(caracter);
+}
+
+Ascii::operator short(void) const {
#ifdef DEBUG
std::cerr << "En cast de Ascii a short." << std::endl;
#endif
/// Comparación por igual de dos instancias.
bool operator==(const Ascii& ascii);
+ /// Cast a char.
+ operator char(void) const;
+
/// Cast a short.
- short int Ascii::operator short int(void);
+ operator short(void) const;
/// Volcado a un stream de salida.
friend std::ostream& operator<<(std::ostream& out, const Ascii& ascii);
# include <iostream>
#endif
-Unicode::Unicode(short c = 0): caracter(c) {
+Unicode::Unicode(short c): caracter(c) {
#ifdef DEBUG
std::cerr << "En constructor de Unicode." << std::endl;
#endif
return caracter == unicode.caracter;
}
-char Unicode::operator char(void) {
+Unicode::operator short(void) const {
+#ifdef DEBUG
+ std::cerr << "En cast de Unicode a char." << std::endl;
+#endif
+ return static_cast<short>(caracter);
+}
+
+Unicode::operator char(void) const {
#ifdef DEBUG
std::cerr << "En cast de Unicode a char." << std::endl;
#endif
return static_cast<char>(caracter);
}
-/// Volcado a un stream de salida.
std::ostream& operator<<(std::ostream& out, const Unicode& unicode) {
#ifdef DEBUG
std::cerr << "En operator<< de Unicode." << std::endl;
return out << unicode.caracter;
}
-/// Captura desde un stream de entrada.
std::istream& operator>>(std::istream& in, const Unicode& unicode) {
#ifdef DEBUG
std::cerr << "En operator>> de Unicode." << std::endl;
bool operator==(const Unicode& unicode);
/// Cast a char.
- char Unicode::operator char(void);
+ operator char(void) const;
+
+ /// Cast a char.
+ operator short(void) const;
/// Volcado a un stream de salida.
- friend std::ostream& operator<<(std::ostream& out, const Unicode& unicode);
+ friend std::ostream& operator<<(std::ostream& out,
+ const Unicode& unicode);
/// Captura desde un stream de entrada.
- friend std::istream& operator>>(std::istream& in, const Unicode& unicode);
+ friend std::istream& operator>>(std::istream& in,
+ const Unicode& unicode);
};