[ create a new paste ] login | about

Link: http://codepad.org/34YZzPB5    [ raw code | output | fork ]

GiM - C++, pasted on Jun 29:
#include <iostream>

class Foo {
 int x;
 friend void bar(Foo&);
public:
 explicit Foo(int x) : x(x) { }
 void foo() { std::cout << "mine's ex: " << x << std::endl; }
};

class Bar : public Foo {
public:
  Bar(int x) : Foo(x) {}
};

void bar(Foo& f) { f.x++; }

int main() {
  char z = 66;
  Bar *f = new Bar(z);
  f->foo();
  bar(*f);
  f->foo();
  return 0;
}


Output:
1
2
mine's ex: 66
mine's ex: 67


Create a new paste based on this one


Comments: