├── PolymorphismCpp
├── PolymorphismCpp.vcxproj.user
├── PolymorphismCpp.vcxproj.filters
├── PolymorphismCpp.cpp
└── PolymorphismCpp.vcxproj
└── PolymorphismCpp.sln
/PolymorphismCpp/PolymorphismCpp.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/PolymorphismCpp/PolymorphismCpp.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;c++;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 |
--------------------------------------------------------------------------------
/PolymorphismCpp/PolymorphismCpp.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | using namespace std;
4 |
5 | class YouTubeChannel {
6 | private:
7 | string Name;
8 | int SubscribersCount;
9 | list PublishedVideoTitles;
10 | protected:
11 | string OwnerName;
12 | public:
13 | YouTubeChannel(string name, string ownerName) {
14 | Name = name;
15 | OwnerName = ownerName;
16 | SubscribersCount = 0;
17 | }
18 | void GetInfo() {
19 | cout << "Name: " << Name << endl;
20 | cout << "OwnerName: " << OwnerName << endl;
21 | cout << "SubscribersCount: " << SubscribersCount << endl;
22 | cout << "Videos: " << endl;
23 | for (string videoTitle : PublishedVideoTitles) {
24 | cout << videoTitle << endl;
25 | }
26 | }
27 | void Subscribe() {
28 | SubscribersCount++;
29 | }
30 | void Unsubscribe() {
31 | if (SubscribersCount > 0)
32 | SubscribersCount--;
33 | }
34 | void PublishVideo(string title) {
35 | PublishedVideoTitles.push_back(title);
36 | }
37 | };
38 |
39 | class CookingYouTubeChannel :public YouTubeChannel {
40 | public:
41 | CookingYouTubeChannel(string name, string ownerName):YouTubeChannel(name, ownerName) {
42 |
43 | }
44 | void Practice() {
45 | cout << OwnerName << " is practicing cooking, learning new recipes, experimenting with spices..." << endl;
46 | }
47 | };
48 |
49 | int main()
50 | {
51 | CookingYouTubeChannel cookingYouTubeChannel("Amy's Kitchen", "Amy");
52 |
53 | system("pause>0");
54 | }
--------------------------------------------------------------------------------
/PolymorphismCpp.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.30309.148
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PolymorphismCpp", "PolymorphismCpp\PolymorphismCpp.vcxproj", "{099A1C17-EAA3-4D30-9CCD-C7C804F810D6}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|x64 = Debug|x64
11 | Debug|x86 = Debug|x86
12 | Release|x64 = Release|x64
13 | Release|x86 = Release|x86
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {099A1C17-EAA3-4D30-9CCD-C7C804F810D6}.Debug|x64.ActiveCfg = Debug|x64
17 | {099A1C17-EAA3-4D30-9CCD-C7C804F810D6}.Debug|x64.Build.0 = Debug|x64
18 | {099A1C17-EAA3-4D30-9CCD-C7C804F810D6}.Debug|x86.ActiveCfg = Debug|Win32
19 | {099A1C17-EAA3-4D30-9CCD-C7C804F810D6}.Debug|x86.Build.0 = Debug|Win32
20 | {099A1C17-EAA3-4D30-9CCD-C7C804F810D6}.Release|x64.ActiveCfg = Release|x64
21 | {099A1C17-EAA3-4D30-9CCD-C7C804F810D6}.Release|x64.Build.0 = Release|x64
22 | {099A1C17-EAA3-4D30-9CCD-C7C804F810D6}.Release|x86.ActiveCfg = Release|Win32
23 | {099A1C17-EAA3-4D30-9CCD-C7C804F810D6}.Release|x86.Build.0 = Release|Win32
24 | EndGlobalSection
25 | GlobalSection(SolutionProperties) = preSolution
26 | HideSolutionNode = FALSE
27 | EndGlobalSection
28 | GlobalSection(ExtensibilityGlobals) = postSolution
29 | SolutionGuid = {B9D38C00-BB46-4E5B-9F5D-AD40A83EAB95}
30 | EndGlobalSection
31 | EndGlobal
32 |
--------------------------------------------------------------------------------
/PolymorphismCpp/PolymorphismCpp.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | Win32
7 |
8 |
9 | Release
10 | Win32
11 |
12 |
13 | Debug
14 | x64
15 |
16 |
17 | Release
18 | x64
19 |
20 |
21 |
22 | 16.0
23 | Win32Proj
24 | {099a1c17-eaa3-4d30-9ccd-c7c804f810d6}
25 | PolymorphismCpp
26 | 10.0
27 |
28 |
29 |
30 | Application
31 | true
32 | v142
33 | Unicode
34 |
35 |
36 | Application
37 | false
38 | v142
39 | true
40 | Unicode
41 |
42 |
43 | Application
44 | true
45 | v142
46 | Unicode
47 |
48 |
49 | Application
50 | false
51 | v142
52 | true
53 | Unicode
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 | true
75 |
76 |
77 | false
78 |
79 |
80 | true
81 |
82 |
83 | false
84 |
85 |
86 |
87 | Level3
88 | true
89 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
90 | true
91 |
92 |
93 | Console
94 | true
95 |
96 |
97 |
98 |
99 | Level3
100 | true
101 | true
102 | true
103 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
104 | true
105 |
106 |
107 | Console
108 | true
109 | true
110 | true
111 |
112 |
113 |
114 |
115 | Level3
116 | true
117 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions)
118 | true
119 |
120 |
121 | Console
122 | true
123 |
124 |
125 |
126 |
127 | Level3
128 | true
129 | true
130 | true
131 | NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
132 | true
133 |
134 |
135 | Console
136 | true
137 | true
138 | true
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
--------------------------------------------------------------------------------