a) Abstract class b) Virtual class c) Singleton class d) Friend class Answer: c ...
View Question
What will be the output of the following C++ code?
#include <iostream>
using namespace std;
class A
{
int a;
A() { a = 5;}
};int main()
{
A *obj = new A;
cout << obj->a;
}
What will be the output of the following C++ code? #include <iostream> using namespace std; class A ...
View Question
Which of the following is correct about new and malloc?
i) new is an operator whereas malloc is a function
ii) new calls constructor malloc does not
iii) new returns required pointer whereas malloc returns void pointer and needs to be typecast
Which of the following is correct about new and malloc? i) new is an operator whereas malloc is ...
View QuestionWhat is the correct syntax of declaring array of pointers of integers of size 10 in C++?
a) int arr = new int[10]; b) int **arr = new int*[10]; c) int *arr = new ...
View Question
What happens if a pointer is deleted twice in a program as shown in the following C++ statements?
int *ptr = new int;
delete ptr;
delete ptr;
What happens if a pointer is deleted twice in a program as shown in the following C++ statements?
View Question
What happens if the following C++ statement is compiled and executed?
int *ptr = NULL;
delete ptr;
What happens if the following C++ statement is compiled and executed? int *ptr = NULL; delete ptr; a) ...
View Question
What will be the output of the following C++ code?
#include <iostream>
using namespace std;
class A{
public:
A(){
cout<<“Constructor called\n”;
}
~A(){
cout<<“Destructor called\n”;
}
};
int main(int argc, char const *argv[])
{
A *a = new A[5];
delete[] a;
return 0;
}
What will be the output of the following C++ code? #include <iostream> using namespace std; class A{ public:
View Question
What will be the output of the following C++ code?
#include <iostream>
using namespace std;
class A{
public:
A(){
cout<<“Constructor called\n”;
}
~A(){
cout<<“Destructor called\n”;
}
};
int main(int argc, char const *argv[])
{
A *a = new A[5];
delete a;
return 0;
}
What will be the output of the following C++ code? #include <iostream> using namespace std; class A{ public:
View QuestionWhat is the difference between delete and delete[] in C++?
a) delete is used to delete normal objects whereas delete[] is used to pointer objects b) delete is ...
View QuestionWhat is virtual inheritance?
a) C++ technique to avoid multiple copies of the base class into children/derived class b) C++ technique to ...
View Question