- What do you know about function templates? Describe it briefly.
- Explain the statement below,
- Give the name of two basic types of containers collectively called First class containers?
- What is difference between simple association and aggregation?
- Enlist the kinds of association with respect to Cardinality.
- Identify and correct the syntax error(s) in the given code snippet?
class Template_class {
private:
T data;
//…
Public:
//…
void input();
};
template< class T >
void Template_class::input( ) {
cin>>data;
}
void main()
{
Template_class <int>obj;
obj.input();
}
- Consider the code below,
template< typename T >
class T1 {
public:
T i;
protected:
T j;
private:
T k;
friend void Test();
};
This code has a template class T1 with three members i,j and k and a friend function Test(), you have to describe which member/s of T1 will be available in function Test().
- Give the general syntax of nested try catch blocks?
- Consider the following code:
int id;
char * name;
public:
Tutor(int, char*){
-------
-------
}
Tutor(const Tutor & obj){
------
------
}
};
Implement copy constructor for the Tutor class by shallow copy and by deep copy.
10. What would be the output of this code?
class mother {
public:
mother ()
{ cout "mother: no parameters\n"; }
mother (int a)
{ cout "mother: int parameter\n"; }
};
class daughter : public mother {
public:
daughter (int a)
{ cout "daughter: int parameter\n\n"; }
};
class son : public mother {
public:
son (int a) : mother (a)
{ cout "son: int parameter\n\n"; }
};
int main () {
daughter rabia (0);
son salman(0);
return 0;
}
11. What is the output produced by the following program?
#include<iostream.h>
void sample_function(double test) throw (int);
int main()
{
try
{
cout ”Trying.\n”;
sample_function(98.6);
cout “Trying after call.\n”;
}
catch(int)
{
cout “Catching.\n”;
}
cout “End program.\n”;
return 0;
}
void sample_function(double test) throw (int)
{
cout “Starting sample_function.\n”;
if(test < 100)
throw 42;
}
12. Write C++ code for the constructor of following template Vector class.
template< class T >
class Vector {
private:
T* ptr;
int size;
int index;
public:
Vector( int = 10 ); // constructor
};
Comments
Post a Comment
Please give us your feedback & help us to improve this site.