What is meant by template parameter in C++?
Which operator is used for input stream in C++?
How many kinds of entities are directly parameterized in C++ through templates?
How many kinds of template parameters are there in C++?
How many number of pointer (*) does C have against a pointer variable declaration?
What is the validity of template parameters in C++?
What will be the output of this C++ program?
#include<iostream>
using namespace std;
class Base
{
public:
void show()
{
cout<<" In Base ";
}
};
class Derived: public Base
{
public:
int x;
void show()
{
cout<<"In Derived ";
}
Derived()
{
x = 10;
}
};
int main(void)
{
Base *bp, b;
Derived d;
bp = &d;
bp->show();
cout << bp->x;
return 0;
}
What is the output of this C++ program?
#include <iostream>
using namespace std;
template<typename T>class clsTemplate
{
public:
T value;
clsTemplate(T i)
{
this->value = i;
}
void test()
{
cout << value << endl;
}
};
class clsChild : public clsTemplate<char>
{
public:
clsChild(): clsTemplate<char>( 0 )
{
}
clsChild(char c): clsTemplate<char>( c )
{
}
void test2()
{
test();
}
};
int main()
{
clsTemplate <int> a( 42 );
clsChild b( 'A' );
a.test();
b.test();
return 0;
}
What will be the output of this C++ program?
#include<iostream>
using namespace std;
class Base
{
public:
int fun() { cout << "Base::fun() called"; }
int fun(int i) { cout << "Base::fun(int i) called"; }
};
class Derived: public Base
{
public:
int fun() { cout << "Derived::fun() called"; }
};
int main()
{
Derived d;
d.fun(5);
return 0;
}
What will be the output of this C++ program?
#include<iostream>
using namespace std;
class Base {
public:
int fun() { cout << "Base::fun() called"; }
int fun(int i) { cout << "Base::fun(int i) called"; }
};
class Derived: public Base {
public:
int fun() { cout << "Derived::fun() called"; }
};
int main() {
Derived d;
d.Base::fun(5);
return 0;
}
What is the output of following C++ program?
#include <iostream>
#include<string>
using namespace std;
class Base
{
public:
virtual string print() const
{
return "This is Base class";
}
};
class Derived : public Base
{
public:
virtual string print() const
{
return "This is Derived class";
}
};
void describe(Base p)
{
cout << p.print() << endl;
}
int main()
{
Base b;
Derived d;
describe(b);
describe(d);
return 0;
}
What will be the output of this C++ program?
#include<iostream>
using namespace std;
class Base
{
protected:
int a;
public:
Base() {a = 0;}
};
class Derived1: public Base
{
public:
int c;
};
class Derived2: public Base
{
public:
int c;
};
class DerivedDerived: public Derived1, public Derived2
{
public:
void show() { cout << a; }
};
int main(void)
{
DerivedDerived d;
d.show();
return 0;
}
What will be the output of this C++ program?
#include<iostream>
using namespace std;
class Base1
{
public:
char c;
};
class Base2
{
public:
int c;
};
class Derived: public Base1, public Base2
{
public:
void show() { cout << c; }
};
int main(void)
{
Derived d;
d.show();
return 0;
}
What is the output of this C++ program?
#include <iostream>
using namespace std;
class Base
{
public:
Base(){}
~Base(){}
protected:
private:
};
class Derived:public Base
{
public:
Derived(){}
Derived(){}
private:
protected:
};
int main()
{
cout << "The program exceuted" << endl;
}
What is the output of this C++ program?
#include <iostream>
using namespace std;
template<typename type>
type Max(type Var1, type Var2)
{
return Var1 > Var2 ? Var1:Var2;
}
int main()
{
int p;
p = Max(100, 200);
cout << p << endl;
return 0;
}
What is the output of this C++ program?
#include <iostream>
using namespace std;
template<typename type>
class Test
{
public:
Test()
{
};
Test()
{
};
type Funct1(type Var1)
{
return Var1;
}
type Funct2(type Var2)
{
return Var2;
}
};
int main()
{
Test<int> Var1;
Test<float> Var2;
cout << Var1.Funct1(200) << endl;
cout << Var2.Funct2(3.123) << endl;
return 0;
}
What is the output of this C++ program?
#include <iostream>
using namespace std;
class class0
{
public:
virtual class0(){ }
protected:
char p;
public:
char getChar();
};
class class1 : public class0
{
public:
void printChar();
};
void class1::printChar()
{
cout << "True" << endl;
}
int main()
{
class1 c;
c.printChar();
return 1;
}
What is the output of this C++ program?
#include <iostream>
using namespace std;
template <class T>
class A
{
public:
A(int a): x(a) { }
protected:
int x;
};
template <class T>
class B: public A<char>
{
public:
B(): A<char>::A(100)
{
cout << x * 2 << endl;
}
};
int main()
{
B<char> test;
return 0;
}
What is the output of this C++ program?
#include <iostream>
using namespace std;
template <class type>
class Test
{
public:
Test();
Test();
type Data(type);
};
template <class type>
type Test<type>::Data(type Var0)
{
return Var0;
}
template <class type>
Test<type>::Test()
{
}
template <class type>
Test<type>::~Test()
{
}
int main(void)
{
Test<char> Var3;
cout << Var3.Data('K') << endl;
return 0;
}
What is the output of this C++ program?
#include <iostream>
using namespace std;
class Base
{
public:
Base ( )
{
cout << "1";
}
Base ( )
{
cout << "2";
}
};
class Derived : public Base
{
public:
Derived ( )
{
cout << "3";
}
Derived ( )
{
cout << "4";
}
};
int main( )
{
Derived x;
}