C++ Programmer Question:

Tell me what is a class?

Tweet Share WhatsApp

Answer:

Class defines a datatype, it's type definition of category of thing(s). But a class actually does not define the data, it just specifies the structure of data. To use them you need to create objects out of the class. Class can be considered as a blueprint of a building, you can not stay inside blueprint of building, you need to construct building(s) out of that plan. You can create any number of buildings from the blueprint, similarly you can create any number of objects from a class.
class Vehicle
{
public:
int numberOfTyres;
double engineCapacity;
void drive(){
// code to drive the car
}
};

Download C++ Programmer PDF Read All 59 C++ Programmer Questions
Previous QuestionNext Question
Tell me what are C++ inline functions?Explain me which operator can be used in C++ to allocate dynamic memory?