Created
August 31, 2013 13:55
-
-
Save jagbolanos/6398362 to your computer and use it in GitHub Desktop.
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> | |
class A { | |
private: | |
int a; | |
public: | |
static double sa; | |
A(int _a) { | |
a = _a; | |
} | |
static void contar() { | |
sa++; | |
} | |
virtual int calcular() { | |
std::cout<<"Calcular A" <<std::endl; | |
} | |
}; | |
class B : public A { | |
private: | |
int b; | |
public: | |
B(int _a, int _b) : A(_a) { | |
b = _b; | |
} | |
}; | |
class C : public B { | |
private: | |
float c; | |
public: | |
static float sc; | |
C(int _a, int _b, float _c) : B(_a, _b) { | |
c = _c; | |
} | |
virtual int calcular() { | |
std::cout<<"Calcular C" <<std::endl; | |
} | |
}; | |
void fporvalor(A param1) { | |
param1.calcular(); | |
} | |
void fporreferencia(A ¶m1) { | |
param1.calcular(); | |
} | |
void fporobjectsharing(A *param1) { | |
param1->calcular(); | |
} | |
int main() { | |
C c1(1, 2, 3.0); | |
fporvalor(c1); | |
fporreferencia(c1); | |
fporobjectsharing(&c1); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment