What are/is the operator/operators used to access the class members?
Dot (.) and Arrow ( -> )
bool
What is the data type to store the Boolean value?
Defining several functions with the same name with unique list of parameters
What is function overloading?
cin, cout, cerr and clog
Name the default standard streams in C++.
Defining a new job for the existing operator w.r.t the class objects is called as
What is operator overloading?
Which access specifier/s can help to achive data hiding in C++?
Private & Protected.
Scope resolution operator (::)
When a class member is defined outside the class, which operator can be used to associate the function definition to a particular class?
What is a destructor? Can it be overloaded?
A destructor is the member function of the class which is having the same name as the class name and prefixed with tilde (~) symbol. It gets executed automatically w.r.t the object as soon as the object loses its scope. It cannot be overloaded and the only form is without the parameter
What is a constructor?
A constructor is the member function of the class which is having the same as the class name and gets executed automatically as soon as the object for the respective class is created.
‘new’ is the operator can be used for the same.
Which operator can be used in C++ to allocate dynamic memory?
Can I use malloc() function of C language to allocate dynamic memory in C++?
Yes, as C is the subset of C++, we can all the functions of C in C++ too.
This, is the pointer variable of the compiler which always holds the current active object’s address.
what is this?
What is the difference between the keywords struct and class in C++?
By default the members of struct are public and by default the members of the class are private
Can we implement all the concepts of OOPS using the keyword struct?
yes
What is a namespace?
A namespace is the logical division of the code which can be used to resolve the name conflict of the identifiers by placing them under different name space.
What are command line arguments?
The arguments/parameters which are sent to the main() function while executing from the command line/console are called so. All the arguments sent are the strings only.
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>
Who designed C++ programming language? with spelling...
Bjarne Stroustrup.
What is the maximum length of an identifier?
Ideally it is 32 characters and also implementation dependent.
What is the output of the following program?
#include<iostream>
using namespace std;
main() { short unsigned int i = 0; cout<<i--;
}
0
What is the output of the following program?#include<iostream>
using namespace std;
main() { char *s = "Fine";
*s = 'N'; cout<<s<<endl;
}
Runtime error
*s=’N’, trying to change the character at base address to ‘N’ of a constant string leads to runtime error.
#include<iostream> using namespace std;
class Empty {};
int main()
{ cout << sizeof(Empty);
return 0; }
1
class Test { int x; };
int main()
{ Test t; cout << t.x;
return 0; }
In C++, the default access is private. Since x is a private member of Test, it is compiler error to access it outside the class.
Predict the output following program
#include<iostream>
using namespace std;
class Test
{ static int x; int *ptr; int y; };
int main()
{ Test t; cout << sizeof(t) << " ";
cout << sizeof(Test *); }
8 4