Explain Class in C++?
Submitted by: AdministratorUser defined data type which contains data and methods to manipulate that data; is known as class. It is the fundamental packaging unit of OO technology. An object is a variable of a Class. Each object is associated with the data of type class with which it is created. Thus we can also say that class is a collection of objects of similar types. It is a user defined data type and behaves like built-in data type of the language. Since class has data and methods to manipulate the data, it supports one of the most important features of OO: Data Encapsulation.
Eg.
class Student
{
int rollno;
int marks1, marks2;
public:
void show(int r); // to print marks
void sum(int r); // to add the marks
};
We can create objects of class using:
class Student s1, s2;
Submitted by: Administrator
Eg.
class Student
{
int rollno;
int marks1, marks2;
public:
void show(int r); // to print marks
void sum(int r); // to add the marks
};
We can create objects of class using:
class Student s1, s2;
Submitted by: Administrator
Read Online C++ Access Control Job Interview Questions And Answers
Top C++ Access Control Questions
☺ | Do you know private, protected and public access control? |
☺ | What is Private Inheritance? |
☺ | Explain different access specifiers for the class member in C++? |
☺ | What is Protected Inheritance? |
☺ | What is Public Inheritance? |
Top C Plus Plus Language Categories
☺ | C++ Pointers & Functions Interview Questions. |
☺ | C++ Operator Overloading Interview Questions. |
☺ | C++ Exception Handling Interview Questions. |
☺ | C++ Virtual Functions Interview Questions. |
☺ | C++ Template Interview Questions. |