what is a class? Explain with an example.
Answer / Amarjeet Kumar Paswan
A class in C++ is a user-defined data type that groups related variables and functions together. It encapsulates (hides) the implementation details from the users of the class, providing only the necessary interface to interact with the class objects. For example:nclass Car {n private:n string brand;n int year;n public:n void setBrand(string b) {n brand = b;n }n void setYear(int y) {n year = y;n }n string getBrand() {n return brand;n }n int getYear() {n return year;n }n};
| Is This Answer Correct ? | 0 Yes | 0 No |
Describe exception handling concept with an example?
What do you mean by pure virtual functions in C++? Give an example?
What does ios :: app do in c++?
Which operator cannot overload?
How do I run a program in notepad ++?
What are references in c++?
What is diamond problem in c++?
What is the most common mistake on c++ and oo projects?
Declare a class vehicle and make it an abstract data type.
Which is not an ANSII C++ function a) sin() b) tmpnam() c) kbhit()
What is the difference between map and hashmap in c++?
Can we declare a base-class destructor as virtual?