Skip to content

Instantly share code, notes, and snippets.

@FraGoTe
Created April 28, 2018 04:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FraGoTe/4b890fc681794b27c23f65f0ec7b5f46 to your computer and use it in GitHub Desktop.
Save FraGoTe/4b890fc681794b27c23f65f0ec7b5f46 to your computer and use it in GitHub Desktop.
#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