Sponsor Area
TextBook Solutions for Uttarakhand Board Class 12 Computer And Communication Technology Computer Science With C++ Chapter 2 Object Oriented Programming
Differentiate between private and public members of a class in the context of Object Oriented Programming. Also, give a suitable example illustrating accessibility/non-accessibility of each using a class and an object in C++.
A class can have multiple public, protected, or private access modifier.
A public class of member or function is accessible from anywhere outside the class but within the program. You can set and get the value of public variables without any member function as shown in the given example.
A private member variable or function cannot be accessed, or even viewed from outside the class. Only the class and friend functions can access private members.By default, all the members of a class would be private, for example.
{
public:int a;
private:int b;
};
int main()
{
MyClass obj;
obj.a =10;//Allowed
obj.b=30;//Not Allowed, gives compiler error}
Write the definition of a function Reverse(int Arr[], int N) in C++, which should reverse the entire content of the array Arr having N elements, without using any other array.
Example: if the array Arr contains
| 13 | 10 | 15 | 20 | 5 |
Then the array should become
| 5 | 20 | 15 | 10 | 13 |
NOTE:
- The function should only rearrange the content of the array.
- The function should not copy the reversed content in another array.
- The function should not display the content of the array.
Sponsor Area
Sponsor Area
Mock Test Series
Mock Test Series



