Advertisement
Guest User

Untitled

a guest
Oct 15th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.46 KB | None | 0 0
  1. //Base.h
  2. #pragma once
  3. class Base
  4. {
  5. public:
  6.     void foo();
  7.     virtual void bar();
  8. };
  9.  
  10. //Base.cpp
  11. #include "Base.h"
  12. void Base::foo()
  13. {
  14. }
  15.  
  16.  
  17. //Derived.h
  18. #pragma once
  19. #include "Base.h"
  20. class Derived : public Base
  21. {
  22. public:
  23.     void bar() override;
  24. }
  25.  
  26. //Derived.cpp
  27. #include "Derived.h"
  28.  
  29. void Derived::bar()
  30. {
  31. }
  32.  
  33. //main.cpp
  34. #include "Derived.h"
  35.  
  36. int main(/**/)
  37. {
  38.     Derived d;
  39.     Base* ptr = &d;
  40.  
  41.     d->foo();
  42.     d->bar();
  43.    
  44.     return 0;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement