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
#include <iostream> | |
using namespace std; | |
class base { | |
int i, j; | |
public: | |
void set(int a, int b) { i = a; j = b; } | |
void mostrar() { cout << i << " " << j << "\n"; } | |
}; | |
class derivada : public base { | |
int k; | |
public: | |
derivada(int x) { k = x; } | |
void mostrar_k() { cout << k << "\n"; } | |
}; | |
int main() | |
{ | |
derivada obj(3); | |
obj.set(1, 2); // accesar a miembro de base | |
obj.mostrar(); // accesar a miembro de base | |
obj.mostrar_k(); // usa miembro de la clase derivada | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment