Chapter 2: Review Questions
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
- a> FALSE
- b> TRUE
- c> FALSE ( hint: most lines of codes are the same in C & C++)
- d> TRUE
- e> TRUE
- f> FALSE
Why do we need the preprocessor directive #include<iostream>?
‘#include<iostream>’ directive causes the preprocessor to add-the contents of iostream file to the program.
How does a main() function in C++ differ from main{} in C?
In C main () by default returns the void type but in C++ it returns integer by default.
What do you think is the main advantage of the comment / / in C++ as compared to the old C type comment?
‘//’ is more easy and time-saving than ‘/* */’
Describe the major parts of a C++ program.
Major parts of a C++ program :
- 1. Include files
- 2. Class declaration
- 3. Member function definitions
- 4. Main function program
Next Previous