Object Oriented Programming - CS304 Spring 2005 Final Term Paper
Object Oriented Programming - CS304 Spring 2005 Final Term Paper
PK
www.vustuff.com
CS304 Object Oriented Programming
Final Term Examination – Spring 2005
Time Allowed: 150 Minutes
class Exception {
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 {
public:
B(){ cout << "Constructor B\n";
if(condition2) //condition two
throw 1;
}
~B(){ cout << "Destructor B\n";}
};
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(...){
throw;
}
}
void Function3(){
cout << "I am Function3\n";
A obj;
Function2();
}
int main() {
try{
Function3();
}
void Function(){
if(condition1){
…
throw Exception();
}
if(condition2){
…
throw DerivedException();
}
if(condition3){
throw 1;
}
}
template< >
class RBTree< int > : public Tree {
// …
};
int main() {
Tree< char > chTree;
RBTree< int > intRBTree;
return 0;
}
b) Consider the following vector class: 20
class Vector {
…
public:
…
int* first();
int* last();
int* next( int* );
};