Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string.h>
- class Base {
- public:
- Base(){}
- virtual void Test() {
- std::cout << "Base\n";
- }
- Base(Base const& b) {
- memcpy((void*)this, (void*)&b, sizeof(Base));
- }
- };
- class Child : public Base{
- public:
- Child(){}
- Child(Child const& b) {
- memcpy((void*)this, (void*)&b, sizeof(Child));
- }
- void Test() {
- std::cout << "Child\n";
- }
- };
- void polyTest(Base x) {
- x.Test();
- }
- int main(int argc, char const *argv[])
- {
- Child child1 = Child();
- polyTest(child1);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement