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
struct punto | |
{ | |
int x; | |
int y; | |
int z = 6; // Inicializador de miembro | |
}; | |
punto p0{}; | |
punto p1{1}; | |
punto p2{1, 2}; |
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
struct punto { int x, y, z; }; | |
struct objeto | |
{ | |
punto posicion; | |
float masa; | |
}; | |
punto puntos0[] {0, 0, 0, 1, 2, 3, 4 , 0, 0}; | |
punto puntos1[] {{0, 0, 0}, {1, 2, 3}, {4, 0, 0}}; |
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 no_agregado1 | |
{ | |
// Constructor definido por el usuario | |
no_agregado1(); | |
}; | |
class no_agregado2 | |
{ | |
// Constructor definido por el usuario | |
no_agregado2(int); |
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
struct agregado | |
{ | |
agregado &operator =(const agregado &a); | |
void funcion(int x); | |
private: | |
static int valor = 1; | |
}; | |
class no_agregado | |
{ |
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
constructor c1{}; // Como construir esto? | |
constructor c2{2}; // Que debe hacerse con el valor 2? | |
privado p{1}; // Imposible acceder al miembro privado! | |
derivada d{} // Que pasa con la tabla virtual? | |
funcion_virtual v{}; // Que pasa con la tabla virtual? | |
objeto o{1}; // El campo i ya esta inicializado! |
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
struct constructor | |
{ | |
// Incumple la restriccion 1 | |
constructor(int) {} | |
}; | |
class privado | |
{ | |
// Incumple la restriccion 2 |
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
// Devuelve un punto con 6 en todos sus campos | |
punto punto6() | |
{ | |
return { 6, 6, 6 }; // Inicializacion por copia! | |
} | |
// Devuelve un objeto en la posicion 0 con 100 de masa | |
objeto objeto100() | |
{ | |
return { {}, 100.f }; // Inicializacion por copia! |
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
punto inicializacion_por_copia = { 1, 2, 3 }; | |
punto inicializacion_directa { 4, 5, 6 }; |
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
uno u; | |
dos d; | |
punto p012 { 0, u, d }; | |
patata frita; | |
objeto primero { p012, 3.f }; | |
objeto segundo { frita, '1' }; | |
objeto tercero { patata{}, dos() }; |
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
// Agregado punto | |
struct punto { int x, y, z; }; | |
// Agregado objeto | |
struct objeto { punto posicion; float masa; }; | |
// Objeto convertible a punto | |
struct patata | |
{ | |
// Operador de conversion a punto |
NewerOlder