0% found this document useful (0 votes)
507 views

OOP Questions

The document contains questions about object-oriented programming concepts. It includes: 1. A class called Circle with data members for xCenter, yCenter, radius, and a static scaleFactor. 2. A program to read integers from input and count how many there are, printing the count. 3. A CAccount class with private data members for accountNumber and accountBalance, and member functions for inputting transactions and printing the balance. 4. Determining errors in code for a CRectangle class and rewriting the correct code. 5. Defining a computer class with a name attribute and print method, and a Macintosh class derived from computer with additional color attribute. 6. Brief notes on

Uploaded by

Gumzz Leo
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
507 views

OOP Questions

The document contains questions about object-oriented programming concepts. It includes: 1. A class called Circle with data members for xCenter, yCenter, radius, and a static scaleFactor. 2. A program to read integers from input and count how many there are, printing the count. 3. A CAccount class with private data members for accountNumber and accountBalance, and member functions for inputting transactions and printing the balance. 4. Determining errors in code for a CRectangle class and rewriting the correct code. 5. Defining a computer class with a name attribute and print method, and a Macintosh class derived from computer with additional color attribute. 6. Brief notes on

Uploaded by

Gumzz Leo
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

OOP Questions Ctt

1. Construct a class named Circle that contains two integer data members named xCenter and yCenter, and a floating point data member named radius. Additionally, the class should contain a static data member named scaleFactor. Here the xCenter and yCenter values represent the center point of a circle, radius represents the circles actual radius, and scaleFactor represents a scale factor that will be used to scale the circle to fit on a variety of display devices. 2. Write a program which reads a sequence of integers and counts how many there are. Print the count. For example, with input 55 1000 20 4 -6 55 0 55, the output should be 8 because there were eight numbers in the input stream. Your program should work for any input, not just this example.

3. Write a class called CAccount which contains two private data elements, an integer accountNumber and a floating point accountBalance, and three member functions: i. A constructor that allows the user to set initial values for accountNumber and accountBalance and a default constructor that prompts for the input of the values for the above data members. ii. A function called inputTransaction, which reads a character value for transactionType ('D' for deposit and 'W' for withdrawal), and a floating point value for transactionAmount, which updates accountBalance. iii. A function called printBalance, which prints on the screen the accountNumber and accountBalance.
4. Determine the errors in the code below and write the replacement code. #include <iostream.h> using namespace std class CRectangle { int x, y; public: void set values (int,int); int area {return (x*y);} }; void CRectangle::set_values (int a, int b) {

x = a, y = b; } int main () { Rectangle rect, rectb; Rect set_values (3,4); Rectb set_values (5,6); cout << "rect area: " << rect.area() << endl; cout << "rectb area: " << rectb.area() << endl; return () 5. Write the definition of a class named "computer" which includes the attribute "name" (the name of the computer) and a print method that prints out this name. It should also include the definition of a class named "Macintosh" that is derived from the class "computer" (computer is the base class) , the attribute "color" (a string) and a method named print that prints out the computer name and color. 6. Write brief notes on the following a) Pointer definition b) Accessing pointer values c) Array definition d) Accessing array values e) String reversal f) Function template g) Class template h) I/O file manipulation i) Error handling j) Namespace k) Type casting

You might also like