Concept explainers
Consider the following class declaration:
class Thing
{
private:
int x;
int y;
static int z;
public:
Thing()
{ x = y = z; }
static void putThing(int a)
{ z = a: }
};
Assume a
Thing one, two, three;
How many separate instances of the x member exist?
How many separate instances of the y member exist?
How many separate instances of the z member exist?
What value will be stored in the x and y members of each object?
Write a statement that will call the PutThing member function before the objects above are defined.
Want to see the full answer?
Check out a sample textbook solutionChapter 14 Solutions
EBK STARTING OUT WITH C++ FROM CONTROL
Additional Engineering Textbook Solutions
Modern Database Management
Starting Out with C++: Early Objects (9th Edition)
Problem Solving with C++ (10th Edition)
Introduction To Programming Using Visual Basic (11th Edition)
Database Concepts (7th Edition)
Starting Out with Programming Logic and Design (4th Edition)
- There are two types of data members in a class: static and non-static. Give an example of real-world use for a static data member.arrow_forwardActivity - Abstract Class An English teacher wants to find assessment mark of all the students in his course. Write a java program to find assessment mark of the students using following instructions. Save the project/file as StudentAbstract. A) Abstract Class name: Assessment Abstract Member Method: - to calculate and return total score totalScore() B) Class name: English extends Assessment Member variables: QuizMark, PracticeTest, ListeningMark Member Method : - Constructor to initialize member variables - to calculate and return total score totalScore QuizMark + PracticeTest*0.25 + %3D ListeningMark/2 C) Controlling class : StudentAbstract - To create an object of English class - To print totalScore of the Englisharrow_forwardT/F: Instance variables are shared by all the instances of the class. T/F: The scope of instance and static variables is the entire class. They can be declared anywhere inside a class. T/F: To declare static variables, constants, and methods, use the static modifier.arrow_forward
- C# languageWrite a program to create a class employee, it consist of ID, name, department and address. All employees belongs to “Computer Science” department and it can never be changed by any means. Employee ID is initialized only once when Employee object is created, any further attempt to change ID should be failed. Class must have a 3 parameterized constructor to set values and two methods: print(): to display all the data of a particular employee totalObjects(): to count and print total number of objects that has been created In Main(), create atleast two objects of employee class, display their records by calling print() function and also print the total number of objects that has been created. [this question is continued on next page] Sample Main Method: static void Main(string[] args) { Employee obj1 = new Employee(1, "Zubair", "Karachi"); obj1.print(); Employee obj2 = new Employee(2, "Nabeel", "Islamabad"); obj2.print();…arrow_forwardIn order to use the assignment operator on an instance of a class data type, it must be overloaded. Group of answer choices True Falsearrow_forwardis the term used to describe the process of making an instance of one class a member of another.arrow_forward
- PROGRAMMING LANGUAGE: C++ SUBJECT: OOP Task: Suppose you have a class Rectangle with data members width and height. The public member functions of class Rectangle are as follows: setValues(int w, int h); // to set values of width and height of objects of Rectangle class int Area();// to find area of an object of rectangle class biggerRectangle(Rectangle A, Rectangle B); prints the rectangle details which is bigger. Sample Code for passing object to a function is given below: #include <iostream> using namespace std; class CRectangle { int width, height; public: void set_values (int, int); int area () {return (width * height);} void copyData(CRectangle rect); }; void CRectangle::copyData(CRectangle rect) { width=rect.width; height=rect.height; cout<<"width of c = "<<width<<", height of c= "<<height<<endl; } void CRectangle::set_values (int a, int b) { width = a; height = b; } int main () { CRectangle a,b,c;…arrow_forwardThe following class declaration has errors. Locate as many as you can. class Yard{private:double length;public:Yard(double l) { length = l; } // double conversion function void operator double() { return length; }... Other member functions follow ...};arrow_forwardThe distinction between a class's static and non-static data members is as follows: Give an example of real-world application where you think a static data member would be useful.arrow_forward
- Computer programmingarrow_forward1. How many members does class test 1 have?arrow_forwardProblem: Employee and ProductionWorker Classes Write a python class named ProductionWorker that is a subclass of the Employee class. The ProductionWorker class should keep data attributes for the following information: • Shift number (an integer, such as 1, 2, or 3)• Hourly pay rateThe workday is divided into two shifts: day and night. The shift attribute will hold an integer value representing the shift that the employee works. The day shift is shift 1 and the night shift is shift 2. Write the appropriate accessor and mutator methods for this class. Once you have written the class, write a program that creates an object of the ProductionWorker class, and prompts the user to enter data for each of the object’s data attributes. Store the data in the object, then use the object’s accessor methods to retrieve it and display it on the screen Note: The program should be written in python. Sample Input/Output: Enter the name: Ahmed Al-AliEnter the ID number: 12345Enter the department:…arrow_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:CengageSystems ArchitectureComputer ScienceISBN:9781305080195Author:Stephen D. BurdPublisher:Cengage Learning