Latest Activity In Study Groups

Join Your Study Groups

VU Past Papers, MCQs and More

We non-commercial site working hard since 2009 to facilitate learning Read More. We can't keep up without your support. Donate.


Help me to Solve these CS304 Question (OOP)

BY

MOHSIN RAZA!!!

Question No: 25      ( Marks: 5 )

 Write C++ code of overloading ^ operator in complex numbers class.

 

If we have two objects of complex number class as follows,

Complex obj1,obj2;  

 

and we write statement,  

 

Complex obj3 = obj1 ^ obj2;

 

obj3 real and imaginary parts will be,

 

obj3.real = (obj1.real) obj2.real and obj3.img = (obj1.img) obj2.img

 

Hint: You can use C++ built in function power(x,y) that returns the result of x y.

 

 

Question No: 25      ( Marks: 5 )

 Suppose we have a Base class Woman and a Derived class Lady Doctor

Describe the case in which we can use derived class “Lady Doctor” Member Initialization List to initialize the base class “Woman” data members. Give a practical example.

 

 

Question No: 26      ( Marks: 5 )

 Consider the following class diagram:

 

Which type of relationship exists between the given classes?

Implement data members and member functions in C++ with appropriate data types (just need prototype).

Implement the relationship between the two classes in C++.

 

 

Question No: 25      ( Marks: 5 )

 How we can use the concept of overloading to convert a type according to our own requirements? Give one example.

 

 

Question No: 26      ( Marks: 5 )

 It is said that the default values of parameters given in constructor should be invalid in normal course of action. Do you agree or not? Justify with solid reasons by giving C++ coding example.

 

 

Question No: 26      ( Marks: 5 )

 Give the c++ code to overload post and pre decrement operators for "Complex Number" class.

 

 

Question No: 26      ( Marks: 5 )

 

Detect and correct compile time error(s) in the following code.

 

#include<iostream.h>

#include<conio.h>

class  Exam

{

      char *ExamName;

      int No_of_paper;

     

public:

       Exam()

       {

             ExamName = "Final Term";

             No_of_paper = 5;

             }

      

void setname( char* name)  const

{

     ExamName = name;

     }

void setpaper(int paper)   const

{

     No_of_paper = paper;

     }

char* getname() 

{

      return ExamName;

      }

int getpaper()

{

    return No_of_paper;

}     

 };

 

int main()

{

const Exam exam1;

cout " Exam            = "exam1.getname()endl;

cout " Numbe of paper  = " exam1.getpaper();

 getch();

return 0;

}

 

 

Question No: 25      ( Marks: 5 )

 Consider the Object Model Diagram given below,

and give the answers of the questions given at the end,

 

 

 

You are required to illustrate above diagram briefly in narrative / textual form.

Also identity at least thee abstract classes from the above diagram.

 



Views: 485

Replies to This Discussion

PLZZZ SHARE UR IDEAS HERE!!!

2nd last question

ANS:

class Exam {

char *ExamName;

 int No_of_paper;

public:

Exam()

{

ExamName = "Final Term";

No_of_paper = 5;

}

void setname( char* name)

{

 ExamName = name;

}

void setpaper(int paper)

{

 No_of_paper = paper;

}

 char* getname()

{

 return ExamName;

}

int getpaper()

{

return No_of_paper;

}

 };

int main()

{

Exam exam1;

 cout " Exam = "exam1.getname()endl;

cout " Number of paper = " exam1.getpaper();

 getch();

return 0;

}

good answer

RSS

© 2021   Created by + M.Tariq Malik.   Powered by

Promote Us  |  Report an Issue  |  Privacy Policy  |  Terms of Service