Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cassert>
- #include <cstring>
- class B{
- float a;
- public:
- B(float);
- virtual ~B();
- virtual void wypisz();
- float getA();
- };
- B::B(float b){
- a = b;
- }
- B::~B(){
- std::cout << "Destruktor klasy bazowej" << std::endl;
- }
- void B::wypisz(){
- std::cout << "A = " << a << std::endl;
- }
- float B::getA(){
- return a;
- }
- class C:public B{
- char * m;
- public:
- C(char *, float);
- ~C();
- void wypisz();
- };
- C::C(char * n, float x):B(x){
- int dlugosc_n = strlen(n);
- m = new char [dlugosc_n + 1];
- assert(m);
- std::strcpy(m,n);
- }
- C::~C(){
- std::cout << "Destruktor klasy pochodnej" << std::endl;
- delete [] m;
- }
- void C::wypisz(){
- std::cout << "m = " << m << " a = " << getA() << std::endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement