Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class Zivotno {
- private:
- char ime[50];
- public:
- Zivotno() {
- }
- Zivotno(char *c) {
- strcpy(ime, c);
- }
- virtual void print_name() {
- cout << "Zivotno: " << ime << endl;
- }
- void f(int x, int y) {
- cout << x << " " << y << endl;
- }
- virtual ~Zivotno() {
- }
- };
- class Kuce : public Zivotno {
- private:
- char rasa[50];
- public:
- Kuce() {
- }
- Kuce(char *ime, char *r) : Zivotno(ime) {
- strcpy(rasa, r);
- }
- void print_name() override {
- cout << "Rasa: " << rasa << endl;
- }
- void f(int x) {
- cout << x << endl;
- }
- ~Kuce() {
- }
- };
- int main() {
- Zivotno *z = new Zivotno("kuce");
- if(dynamic_cast<Kuce*>(z)) {
- cout << "kuce" << endl;
- }
- else {
- cout << "zivotno" << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement