Skip to content

Instantly share code, notes, and snippets.

@SergNikitin
Last active December 24, 2015 20:08
Show Gist options
  • Save SergNikitin/6855194 to your computer and use it in GitHub Desktop.
Save SergNikitin/6855194 to your computer and use it in GitHub Desktop.
Virtual functions overload test
#include <iostream>
class A {
public:
virtual int foo(int *num) {
const int height = 150; //in cm
int sum = height + *num;
std::cout << sum << std::endl;
return sum;
};
};
class B : public A {
public:
std::string foo(std::string name) {
const std::string surname = "Kelso";
std::string fullName = name + " " + surname;
return fullname;
};
};
int main {
B b;
int delta = 10;
std::cout << b.foo(*delta) << std::endl;
std::cout << b.foo("Bob") << std::endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment