Skip to content

Instantly share code, notes, and snippets.

@FraGoTe
Created Apr 28, 2018
Embed
What would you like to do?
#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