VU CS304- Object Oriented Programming LATEST SOLVED SUBJECTIVES FROM MIDTERM PAPERS 2011 Part1
MIDTERM EXAMINATION 2011
Q.1 can constant object access the none constant member function of each class.
Answer:- (Page 106)
"Const objects can access only const member functions so chances of change of state of const objects once they
are created are eliminated."
Q.2. Give at least two problems that we should check when we overloading assignments operator ("=") in
string class (unsolved)
Q3. Give c++ code to overloaded unary "--" oprators to comples member class.
Answer:- (Page 165)
class Complex{
...
Complex operator -- (int);
// friend Complex operator --(const Complex &, int);
}
Complex Complex::operator -- (int){
complex t = *this;
real - = 1;
return t;
}
Complex operator -- (const
Complex & h, int){
complex t = h;
h.real - = 1;
return t;
}
Q4.What is simple association? Explain it with the help of example.
Answer:- (Page 49)
The two interacting objects have no intrinsic relationship with other object. It is the weakest link between
objects. It is a reference by which one object can interact with some other object.
• Customer gets cash from cashier
• Employee works for a company
Q5.explain the deference between the static variable of a class with none static variable with the help of
example
Answer:- click here for detail
The difference between static and non static members is only that a non static member is tied to an instance of a
class although a static member is tied to the class, and not to a particular instance. That is, a static member is
shared by all instances of a class although a non static member exists for each instance of class.
Q.1 can constant object access the none constant member function of each class.
Answer:- (Page 106)
"Const objects can access only const member functions so chances of change of state of const objects once they
are created are eliminated."
Q.2. Give at least two problems that we should check when we overloading assignments operator ("=") in
string class (unsolved)
Q3. Give c++ code to overloaded unary "--" oprators to comples member class.
Answer:- (Page 165)
class Complex{
...
Complex operator -- (int);
// friend Complex operator --(const Complex &, int);
}
Complex Complex::operator -- (int){
complex t = *this;
real - = 1;
return t;
}
Complex operator -- (const
Complex & h, int){
complex t = h;
h.real - = 1;
return t;
}
Q4.What is simple association? Explain it with the help of example.
Answer:- (Page 49)
The two interacting objects have no intrinsic relationship with other object. It is the weakest link between
objects. It is a reference by which one object can interact with some other object.
• Customer gets cash from cashier
• Employee works for a company
Q5.explain the deference between the static variable of a class with none static variable with the help of
example
Answer:- click here for detail
The difference between static and non static members is only that a non static member is tied to an instance of a
class although a static member is tied to the class, and not to a particular instance. That is, a static member is
shared by all instances of a class although a non static member exists for each instance of class.
No comments:
Post a Comment