Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- class A
- {
- public:
- int bob;
- A()
- {
- bob = 4;
- }
- };
- class B : public A
- {
- public:
- int magic;
- B()
- {
- bob = 5;
- magic = 42;
- }
- };
- void evilFunc(A as[])
- {
- A a;
- as[0] = a;
- as[1] = a;
- }
- int main(void)
- {
- B bs[2];
- evilFunc(bs);
- std::cout << bs[0].magic << " " << bs[0].bob << std::endl;
- std::cout << bs[1].magic << " " << bs[1].bob << std::endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement