C++ Programming Question and Answers

61. What is a class?
 
  • Class is a user defined data type in C++.
  • It can be created to solve a particular kind of problem.
  • After creation the user need not know the specifies of the working of a class.
 
Your Name Your Email-ID
Your Answer
62. What is the difference between an object and a class?
 
  • Classes and objects are separate but related concepts. Every object belongs to a class and every class contains one or more related objects.
  • A Class is static. All of the attributes of a class are fixed before, during, and after the execution of a program. The attributes of a class don't change.
  • The class to which an object belongs is also (usually) static. If a particular object belongs to a certain class at the time that it is created then it almost certainly will still belong to that class right up until the time that it is destroyed.
  • An object on the other hand has a limited lifespan. Objects are created and eventually destroyed. Also during that life lifetime, the attributes of the objects may undergo significant change.
 
Your Name Your Email-ID
Your Answer
63. What is abstraction?
  Abstraction is of the process of hiding unwanted details from the user.
 
Your Name Your Email-ID
Your Answer
64. What is the difference between new() and calloc()?
 
  • new () allocates continous space for the object instance malloc() allocates distributed space.
  • new() is castles, meaning that allocates memory for this specific type, malloc(), calloc() allocates space for void * that is created to the specific class type pointer.
 
Your Name Your Email-ID
Your Answer
65. What is difference between class and structure?
 
  • Structure: Initially (in C) a structure was used to bundle different types together to perform a particular functionality. But C++ extended the structure to contain functions also. The major difference is that all declarations inside a structure are by default public.
  • Class: class is a successor of Structures. By default all the members inside the class are private.
 
Your Name Your Email-ID
Your Answer
123456789101112


131415 Page 13 of 15