Advertisement
emaansahmed

Assignment #4

Apr 26th, 2015
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.45 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. class A
  4. {
  5. private:
  6. int n;
  7. public:
  8. A(); A(int a); void f(); void g();
  9. int h() const; void k() const;
  10. };
  11. A::A() {n = 0;} A::A(int a) {n = a;}
  12. void A::f() {n++;} void A::g() {f(); n = 2*n; f();}
  13. int A::h() const {return n;}
  14. void A::k() const {cout << n << endl;}
  15. int main()
  16. {
  17. A a; A b(2); A c; A d(3);
  18. a.f(); b.g(); c.f(); d.g(); d.k();
  19. A e(a.h() + b.h() + c.h()); e.k();
  20. return 0;
  21. } // end of main
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement