We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent fb59143 commit 02118afCopy full SHA for 02118af
tricky-oops-problem.cpp
@@ -0,0 +1,35 @@
1
+//g++ 5.4.0
2
+//Are private functions really private? Well...
3
+//Checkout video at: https://youtu.be/TVKsaq7Bohs
4
+#include <bits/stdc++.h>
5
+
6
+using namespace std;
7
8
+class SocialWebsite{
9
+private:
10
+protected:
11
+public:
12
+ virtual void secret() {} ;
13
+};
14
15
+class Facebook: public SocialWebsite{
16
17
+ string fbPassword;
18
19
+ void secret(){
20
+ cout << "The Facebook password is: " << fbPassword << endl;
21
+ cout << "Its risky, but its fine to print here as it's a private function\n";
22
+ }
23
24
+ Facebook(string pwd) {
25
+ fbPassword = pwd;
26
27
28
29
+int main()
30
+{
31
+ Facebook f("Rachit95@fb");
32
33
+ SocialWebsite *ptr = &f;
34
+ ptr->secret();
35
+}
0 commit comments