Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ConsoleApplication38.cpp : Этот файл содержит функцию "main". Здесь начинается и заканчивается выполнение программы.
- //
- #include <iostream>
- using namespace std;
- class Shape
- {
- public:
- virtual void printShapeName() = 0;
- //{
- // cout << "Shape" << endl;
- //}
- };
- class Circle: public Shape
- {
- public:
- void printShapeName()
- {
- cout << "Circle" << endl;
- }
- };
- class Cylinder: public Shape
- {
- public:
- void printShapeName()
- {
- cout << "Cylinder" << endl;
- }
- };
- int main()
- {
- Cylinder a;
- Circle b;
- //Shape c;
- Shape* ptr;
- /*ptr = &c;*/
- ptr = &a;
- ptr->printShapeName();
- ptr = &b;
- ptr->printShapeName();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement