CS304 Midterm Past Paper Spring 2005
- Type
- Midterm past paper
- Course
- CS304 Object Oriented Programming
- Size
- PDF 164 KB
- Updated
- 23 Oct 2026
You get 3 free files a day on the website. Add the Chrome extensionSign in with the extension for 30 a day.
Preview text
Text from pages 1, 2 of 2. Download the file for all 2 pages.
Mid Term Examination – Spring 2005
d. All coding questions should be answered using the C ++ syntax.
You are allowed to use the Dev-C++ compiler to write and test your code. If you do so please remember to copy and paste your code into the examination
Total Marks: 40 Total Questions: 3
Q1. Design and implement a String class that makes the following code work properly. The class should store the string in a dynamically allocated memory.
int main()
String X, Y = " World!"; X = " Hello " + Y; cout<< X << endl; return 0;
Q2.
1. Assignment of private data members at the time of object creation. 2. When an object is passed by vale to a function. 3. When allocating memory dynamically we use copy constructor to avoid dangling pointer issue.
Q3. class Complex
private:
double x,y; static int z;
public:
Complex(double = 0.0); friend ostream& operator<<(ostream&, const Complex&); static int doSomething( ) { z = 2 * y; return z; }
a. What is wrong in the definition of member function doSomething( ). 03
Answer: Static keyword because using static key word we are declaring a static member function doSomething(). Which can not use non static data members. b. What will be the effect of writing the friend function operator<<(…) in private part of the above class? 02
Answer: There will be no effect on friend function if we write it in private part. Friend function is a friend function and can use any private or public data member of the class. Where ever we declare it in class body.
Related CS304 files
All CS304 files →- CS304 Midterm Past Paper Spring 2006 Midterm PDF 129 KB
- CS304 Midterm Mega Quiz Spring 2020 Midterm PDF 4.8 MB
- CS304 Midterm Quizzes 2023 by Danish Hanif Midterm PDF 277 KB
- CS304 Midterm Notes (Word) Midterm DOCX 33 KB
- CS304 Highlighted Handouts Lectures 1-45 Set 2 Highlighted PDF 7.7 MB
- CS304 Assignment 3 Solution Fall 2022 by VUBuddy Assignment DOCX 82 KB
Get more out of VUBuddy, for free
- Unlimited downloads
- The explanation behind every MCQ answer
- Study offline on slow data
- 30 downloads a day instead of 3
- Sign in and buy Pro Semester here
One Pro Semester membership works in both the extension and the app.