Escolar Documentos
Profissional Documentos
Cultura Documentos
question.
t e r i a
1. Attempt all questions. Marks are written adjacent to each
C a f e
a. If you think that there is something wrong with any of
the questions, attempt it to the best of your understanding.
b. If you believe that some essential piece of information is
class Exception {
Page 1 / 5
Note: Solve these papers by yourself
VU Cafeteria is not responsible for any solved content
VU Cafeteria
protected:
char message [30] ;
public:
Exception() {strcpy(message,"Exception");}
char * what() { return message; }
};
class A {
public:
A(){ cout << "Constructor A\n";}
~A(){
cout << "Destructor A\n";
if(condition1) //condition one
throw Exception();
}
};
class B {
t e r i a
public:
a f
B(){ cout << "Constructor B\n";
if(condition2) //condition
C throw 1;
e two
U
}
~B(){ cout << "Destructor B\n";}
V
};
void Function1() {
DerivedException DE;
cout << "I am Function1" << endl;
if(condition3) //condition three
{
throw DE;
}
}
void Function2() {
cout << "I am Function2\n" << endl;
try{
B obj2;
Function1();
}
catch(int)
{
throw 10.1;
}
catch(...){
Page 2 / 5
Note: Solve these papers by yourself
VU Cafeteria is not responsible for any solved content
VU Cafeteria
throw;
}
}
void Function3(){
cout << "I am Function3\n";
A obj;
Function2();
}
int main() {
try{
Function3();
}
t e r i a
}
catch(...){
}
a f e
cout << "Exception: unknown\n";
C
}
a.
V U return
cout << "End of Program\n";
0;
void Function(){
if(condition1){
…
throw Exception();
}
if(condition2){
…
throw DerivedException();
}
if(condition3){
Page 3 / 5
Note: Solve these papers by yourself
VU Cafeteria is not responsible for any solved content
VU Cafeteria
throw 1;
}
}
template< >
class RBTree< int > : public Tree {
// …
};
int main() {
t e r i a
e
Tree< char > chTree;
}
return 0;
C a f
RBTree< int > intRBTree;
V U class Vector {
public:
…
int*
…
first();
int* last();
int* next( int* );
};
Page 4 / 5
Note: Solve these papers by yourself
VU Cafeteria is not responsible for any solved content
VU Cafeteria
t e r i a
C a f e
V U
Page 5 / 5
Note: Solve these papers by yourself
VU Cafeteria is not responsible for any solved content