Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class Animal {
- private:
- char * ime;
- int godini;
- bool pitomo;
- public:
- Animal() {}
- Animal(char * _ime, int _godini, bool _pitomo) {
- ime = new char[strlen(ime)];
- strcpy(ime, _ime);
- godini = _godini;
- pitomo = _pitomo;
- }
- ~Animal() {
- delete[] ime;
- }
- char * get_ime() {
- return ime;
- }
- int get_godini() {
- return godini;
- }
- bool get_pitomo() {
- return pitomo;
- }
- };
- class Cat : public Animal {
- private:
- char * vid_na_macka;
- public:
- Cat() : Animal() {
- }
- Cat(char * _ime, int _godini, bool _pitomo, char * _vid_na_macka) : Animal(_ime, _godini, _pitomo) {
- vid_na_macka = new char[strlen(_vid_na_macka)];
- strcpy(vid_na_macka, _vid_na_macka);
- }
- ~Cat() {
- delete[] vid_na_macka;
- }
- char * get_vid_na_macka() {
- return vid_na_macka;
- }
- };
- int main()
- {
- Cat c("tom", 5, false, "ulicna");
- cout << c.get_godini() << endl;
- cout << c.get_ime() << endl;
- cout << c.get_vid_na_macka() << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement