This post lists the C++ Programming FAQ (Frequently Asked Questions and answers) for freshers for next job interview or C++ Programming exam.
C++ is an object-oriented programming language. It is a superset of C-language that has all the features of the C programming language.
#include<iostream.h> is included in c++ programs. '#' stands for preprocessor directive. iostream stands for the input-output stream. include is used to add the functionality of the iostream file in the program.
It is a piece of code ignored by the compiler. It is written by the programmer to add the descriptive information about the source code.
It supports features of C-language. The additional features C++ supports are:
Bjarne Stroustrup
The class is the user-defined data type. The class is defined with the class keyword. A class is a blueprint of a class. It is a collection of functions and related data under a single name.
SYNTAX:
class class_name{
// data member
// Member functions
}
An Object is an instance of the class. it is the run-time entity. The class does not occupy any memory space. When an object is created with a new keyword then memory is occupied.
There are two ways through which you can define the constant:
It is a process of binding the data members and member functions in a single class. It prevents direct access to the data for security purposes.
It sorts out the name conflict of the identifier, which is skilled by placing them under numerous namespaces. It particularly helped in the logical division of the multiple codes.
An abstraction in C++ means the process of hiding important information from the outside world and displaying the required information only.
In the term, polymorphism poly means multiple, and morphism means the same form. It means we can define different functions with the same name but with different functionalities.
There are two types of polymorphism:
Access specifier defines the scope of the class members i.e data members and member functions. The scope here means whether the member function is accessible outside class or not. If it is accessible, up to which we can use the class members i.e inside the class, outside the class, and anywhere in the program.
There are three types of access specifier:
It helps in declaring the variable as volatile. It means the value of the volatile variable is not copied to the register from memory. The operations are performed outside. The value of the volatile variable is never appeared to be modified but the value changes in different accesses.
A friend function is declared inside the class but defined outside the class. A friend function has the right to access all the private and protected members of the class. It is not a member function of the class. A friend can be a member function, class, and function. In the case of class, the entire class is a friend and all its members also.
To avoid the function overheads in the program, C++ come up with the new functionality known as the inline function. An inline function is expanded in a single line. The inline function replaces the function call by the compiler through the entire code. It improvises the execution time of the program.
Yes, the inline function can be called recursively. The major disadvantage of calling the inline function recursively is wastage of memory but it saves the time of CPU in execution.
Pointers are nothing but a variable that the address of another variable. Pointers can be defined with different types of data types. A character type pointer holds the address of the character type variable. Through pointers, programs are stimulating call-by-reference.