Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
Manishak798 authored Feb 14, 2024
1 parent b947059 commit 6d34ffb
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions OOPS/protected.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#include <bits/stdc++.h>
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;
}

0 comments on commit 6d34ffb

Please sign in to comment.