When should we use the register storage specifier?
If a variable is used most frequently then it should be declared using register storage specifier, then possibly the compiler gives CPU register for its storage to speed up the look up of the variable.
Can a program be compiled without main() function?
Yes, it can be but cannot be executed, as the execution requires main() function definition.
Where an automatic variable is stored?
Every local variable by default being an auto variable is stored in stack memory
What is a container class?
A class containing at least one member variable of another class type in it is called so.
What is a token?
A C++ program consists of various tokens and a token is either a keyword, an identifier, a constant, a string literal, or a symbol.
What is a preprocessor?
Preprocessor is a directive to the compiler to perform certain things before the actual compilation process begins.
What are command line arguments?
The arguments which we pass to the main() function while executing the program are called as command line arguments. The parameters are always strings held in the second argument (below in args) of the function which is array of character pointers. First argument represents the count of arguments (below in count) and updated automatically by operating system.
main( int count, char *args[]) {
}
What are the different ways of passing parameters to the functions? Which to use when?
• Call by value - We send only values to the function as parameters. We choose this if we do not want the actual parameters to be modified with formal parameters but just used.
• Call by address - We send address of the actual parameters instead of values. We choose this if we do want the actual parameters to be modified with formal parameters.
• Call by reference - The actual parameters are received with the C++ new reference variables as formal parameters. We choose this if we do want the actual parameters to be modified with formal parameters.
What is reminder for 5.0 % 2?
Error, It is invalid that either of the operands for the modulus operator (%) is a real number.
Which compiler switch to be used for compiling the programs using math library with g++ compiler?
Opiton –lm to be used as > g++ –lm file.cpp
Can we resize the allocated memory which was allocated using ‘new’ operator?
No, there is no such provision available.
Who designed C++ programming language?
Bjarne Stroustrup.
Which operator can be used to determine the size of a data type/class or variable/object?
sizeof
How can we refer to the global variable if the local and the global variable names are same?
We can apply scope resolution operator (::) to the for the scope of global variable. What are valid operations on pointers?
The only two permitted operations on pointers are
• Comparision ii) Addition/Substraction (excluding void pointers)
What is recursion?
Function calling itself is called as recursion.
What is the first string in the argument vector w.r.t command line arguments?
Program name.
What is the maximum length of an identifier?
Ideally it is 32 characters and also implementation dependent.
What is the default function call method?
By default the functions are called by value.
What are available mode of inheritance to inherit one class from another?
Public, private & protected
What is the difference between delete and delete[]?
Delete[] is used to release the array allocated memory which was allocated using new[] and delete is used to release one chunk of memory which was allocated using new.
Does an abstract class in C++ need to hold all pure virtual functions?
Not necessarily, a class having at least one pure virtual function is abstract class too.
Is it legal to assign a base class object to a derived class pointer?
No, it will be error as the compiler fails to do conversion.
What happens if an exception is thrown outside a try block?
The program shall quit abruptly.
Are the exceptions and error same?
No, exceptions can be handled whereas program cannot resolve errors.
What is function overriding?
Defining the functions within the base and derived class with the same signature and name where the base class’s function is virtual.
Which function is used to move the stream pointer for the purpose of reading data from stream?
seekg()
Which function is used to move the stream pointer for the purpose of writing data from stream?
seekp()
Are class functions taken into consideration as part of the object size?
No, only the class member variables determines the size of the respective class object.
Can we create and empty class? If so what would be the size of such object.
We can create an empty class and the object size will be 1.
What is ‘std’?
Default namespace defined by C++.
What is the full form of STL?
Standard template library
What is ‘cout’?
cout is the object of ostream class. The stream ‘cout’ is by default connected to console output device.
What is ‘cin’?
cin is the object of istream class. The stream ‘cin’ is by default connected to console input device.
What is the use of the keyword ‘using’?
It is used to specify the namespace being used in.
If a pointer declared for a class, which operator can be used to access its class members?
Arrow (->) operator can be used for the same
What is difference between including the header file with-in angular braces < > and double quotes “ “
If a header file is included with in < > then the compiler searches for the particular header file only with in the built in include path. If a header file is included with in “ “, then the compiler searches for the particular header file first in the current working directory, if not found then in the built in include path
S++ or S = S+1, which can be recommended to increment the value by 1 and why?
S++, as it is single machine instruction (INC) internally.
What is the difference between actual and formal parameters?
The parameters sent to the function at calling end are called as actual parameters while at the receiving of the function definition called as formal parameters.
What is the difference between variable declaration and variable definition?
Declaration associates type to the variable whereas definition gives the value to the variable.
Which key word is used to perform unconditional branching?
goto.
Is 068 a valid octal number?
No, it contains invalid octal digits.
What is the purpose of #undef preprocessor?
It will be used to undefine an existing macro definition.
Can we nest multi line comments in a C++ code?
No, we cannot.
What is a virtual destructor?
A virtual destructor ensures that the objects resources are released in the reverse order of the object being constructed w.r.t inherited object.
What is the order of objects destroyed in the memory?
The objects are destroyed in the reverse order of their creation.
What is a friend class?
A class members can gain accessibility over other class member by placing the class declaration prefixed with the keyword ‘friend’ in the destination class.
Source: Contents are provided by Technicalsymposium Google Group Members. Disclaimer: All the above contents are provided by technicalsymposium.com Google Group members. Further, this content is not intended to be used for commercial purpose. Technicalsymposium.com is not liable/responsible for any copyright issues.
Technicalsymposium.com-All Quick Links & Study Notes PDF- Free Download
|
|