go to start Sol W13
|home |print view |recent changes |changed December 10, 2018 |
exact
|You are 54.167.15.6 <- set your identity!

#include <iostream>
struct Base {
  virtual void function() const{std::cout << "1";}
};

struct Derived : Base {
  void function() const {std::cout << "2";}
};

void call_function(Base &b) {
  b.function();
}

int main() {
  Derived d{};
  call_function(d);
  Base b{};
  call_function(b);
}
outputs 21

try with http://melpon.org/wandbox


|home |print view |recent changes |changed December 10, 2018 |
exact
|You are 54.167.15.6 <- set your identity!

Sol W13
go to start