Last active
December 24, 2015 20:08
-
-
Save SergNikitin/6855194 to your computer and use it in GitHub Desktop.
Virtual functions overload test
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 { | |
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