Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /////////// PLIK .h /////////////////////////////
- #pragma once
- #include <string>
- class A {
- public:
- virtual std::string getName() = 0;
- friend std::string getNameFriend();
- };
- class B : public A {
- public:
- virtual ~B();
- virtual std::string getName();
- };
- class C : public B {
- public:
- virtual ~C();
- virtual std::string getName();
- };
- ///////////////// PLIK .cpp ////////////////////////////////////
- #include "stdafx.h"
- #include "Paradygmaty1.h"
- B::~B()
- {
- }
- std::string B::getName()
- {
- return "B";
- }
- C::~C()
- {
- }
- std::string C::getName()
- {
- return "C";
- }
- std::string getNameFriend()
- {
- return "A";
- }
- ///////////////// Main.cpp ///////////////////////////////////////////
- #include "stdafx.h"
- #include <iostream>
- #include <conio.h>
- #include "Paradygmaty1.h"
- int main()
- {
- A *a = new B();
- A *a2 = new C();
- std::cout << getNameFriend() << " -> " << a->getName() << " -> " << a2->getName();
- delete a;
- delete a2;
- _getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement