juyana

inheritance

Apr 26th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. typedef long long ll;
  6. #define pb push_back
  7. #define mpk make_pair
  8. #define N 1001
  9. #define PI acos(-1.0)
  10. #define Mn 1000000007
  11.  
  12. class BaseClass
  13. {
  14. public:
  15. ll a;
  16. BaseClass(ll n)
  17. {
  18. a=n;
  19. }
  20. };
  21.  
  22. class DerivedClass: public BaseClass
  23. {
  24. public:
  25. ll b;
  26. DerivedClass(int x,int y):BaseClass(x)
  27. {
  28. b=y;
  29. }
  30. };
  31.  
  32. int main()
  33. {
  34.  
  35. DerivedClass o1(2,3);
  36. cout<<o1.a<<" "<<o1.b<<endl;
  37. return 0;
  38. }
Add Comment
Please, Sign In to add comment