Chapter 2: Review Questions

2.1

State whether the following statements are TRUE or FALSE.
(a) Since C is a subset of C++, all C peograms will run under C++ compilers.
(b) In C++, a function contained within a class is called a member function.
(c) Looking at one or two lines of code, we can easily recognize whether a program is written in C or C++.
(d) In C++, it is very easy to add new features to the existing structure of an object.
(e) The concept of using one operator for different purposes is known as aerator overloading. 10 The output function printfl) cannot be used in C++ programs

 

Answer
  • a> FALSE
  • b> TRUE
  • c> FALSE   ( hint: most lines of codes are the same in C & C++)
  • d> TRUE
  • e> TRUE
  • f> FALSE
2.2

Why do we need the preprocessor directive #include<iostream>?

 

Answer

‘#include<iostream>’ directive causes the preprocessor to add-the contents of iostream file to the program.

 

2.3

How does a main() function in C++ differ from main{} in C?

 

Answer

In C main () by default returns the void type but in C++ it returns integer by default.

 

2.4

What do you think is the main advantage of the comment / / in C++ as compared to the old C type comment?

 

Answer

‘//’ is more easy and time-saving than ‘/* */’

 

2.5

Describe the major parts of a C++ program.

 

Answer

Major parts of a C++ program :

  • 1. Include files
  • 2. Class declaration
  • 3. Member function definitions
  • 4. Main function program

 


Next Previous