Skip to content

Tag Archives: Constructors

#include<iostream> using namespace std;    class Test { public:    Test(Test &t) { }    Test()        { } };    Test fun() {     cout << "fun() Called\n";… Read More
Predict the output of following program? #include <iostream> using namespace std; class Test { private:     int x; public:     Test(int i)     {         x = i;         cout… Read More
#include<iostream> using namespace std;     class Test { public:   Test(); };     Test::Test()  {     cout << " Constructor Called. "; }     void fun() {… Read More
Which of the following is true about constructors. 1) They cannot be virtual. 2) They cannot be private. 3) They are automatically called by new… Read More
We must use initializer list in a constructor when (A) There is a reference variable in class (B) There is a constant variable in class… Read More
Predict the output of following program. #include<iostream> using namespace std; class Point {     int x; public:     Point(int x) { this->x = x; }     Point(const Point… Read More
Output? #include<iostream> #include<string.h> using namespace std;    class String {     char *str; public:      String(const char *s);      void change(int index, char c) { str[index] = c;… Read More
<br> #include < iostream ><br> using namespace std;<br><br>    class Test<br> {<br> public:<br> Test() { cout << "Hello from Test() "; }<br> } a;<br><br>   … Read More
Predict the output of following program. #include<iostream> #include<stdlib.h> using namespace std;    class Test { public:    Test()    { cout << "Constructor called"; } };   … Read More
#include <iostream> using namespace std;    class Point {     int x, y; public:    Point(int i = 0, int j = 0) { x = i;… Read More
What is the output of following program? #include <iostream> using namespace std;    class Point {     int x, y; public:    Point(const Point &p) { x… Read More
#include<iostream> using namespace std;    class X  { public:     int x; };    int main() {     X a = {10};     X b = a;     cout… Read More
Output of following program? #include<iostream> using namespace std;    class Point { public:     Point() { cout << "Normal Constructor called\n"; }     Point(const Point &t) {… Read More
#include<iostream> using namespace std; class Point { public:     Point() { cout << "Constructor called"; } };    int main() {    Point t1, *t2;    return 0;… Read More
Output of following program? <br> #include < iostream ><br> using namespace std;<br> class Point {<br> Point() { cout << "Constructor called"; }<br> };<br><br>    int… Read More

Start Your Coding Journey Now!