From 6d34ffb188d377dd3314734790de713d799198b4 Mon Sep 17 00:00:00 2001 From: Manisha Kundnani <90680330+Manishak798@users.noreply.github.com> Date: Wed, 14 Feb 2024 09:19:35 +0530 Subject: [PATCH] Add files via upload --- OOPS/protected.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 OOPS/protected.cpp diff --git a/OOPS/protected.cpp b/OOPS/protected.cpp new file mode 100644 index 0000000..799b984 --- /dev/null +++ b/OOPS/protected.cpp @@ -0,0 +1,29 @@ +#include +using namespace std; +class Employee +{ +protected: // it can be accessed in the inherited class + int salary; +}; +class Programmer : public Employee +{ +public: + int bonus; + void setsalary(int s) + { + salary = s; + } + int getsalary() + { + return salary; + } +}; +int main() +{ + Programmer Obj; + Obj.setsalary(500000); + Obj.bonus = 15000; + cout << "Salary: " << Obj.getsalary() << endl; + cout << "Bonus: " << Obj.bonus; + return 0; +} \ No newline at end of file