codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
#include <iostream> #include <vector> class A { public: int a, b, c; A() { a=1; b=2; c=3; std::cout << "constr" << a << ":" << b << ":" << c << std::endl; } void pokaz() { std::cout << "blurp" << a << ":" << b << ":" << c << std::endl; } }; class B : public A { int x,y,z,u,v; public: B() { std::cout << " w konstr B: " << this << " ] " << std::endl; } int bing(int x) { return (x+2); } }; typedef std::vector<A*> Weka; int main() { Weka wek; Weka::iterator wek_i; A *tempA; B *tempB; wek.push_back(new B); wek.push_back(new B); wek.push_back(new B); wek.push_back(new B); int x=0; for (wek_i = wek.begin(); wek_i != wek.end(); wek_i++, x++) { tempA = *wek_i; tempA->a = 6 +x; tempA->pokaz(); } for (wek_i = wek.begin(); wek_i != wek.end(); wek_i++, x++) { tempB = static_cast<B*>(*wek_i); tempB->b = 10+x; tempB->pokaz(); tempB->bing(2); } return 0; }
Private
[
?
]
Run code
Submit