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
Mylab Programming With Pearson Etext -- Access Card -- For Starting Out With C++: From Control Structures Through Objects, Brief Version
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)
- Mark the following statements as true or false. The member variables of a class must be of the same type. (1) The member functions of a class must be public. (2) A class can have more than one constructor. (5) A class can have more than one destructor. (5) Both constructors and destructors can have parameters. (5)arrow_forwardwrite the definition of the class Rectangle containing: length: a private data member of type double width: a private data member of type double a default constructor that assigns the values 20 and 10 length and width, respctively. an overloading constructor that accepts two parameters of type double and assigns them to length and width. an overloading constructor that accepts one parameter of type double and assigns it to both length and width setLength: a member function that accepts a double parameter and assigns it to length if it is positive(gerater than zero). setWidth: a member function that accepts a double parameter and assigns it to width if it is positive(gerater than 0) getLength: a member function that accepts no parameter and returns the value of length getWidth: a meber function that accepts no parameters and returns the value of width getAre: a member function that accepts no parameters and returns the area of the rectangle.arrow_forwardUse the following partial class definitions to answer the questions a-c public class A1 { public int x; private int y; protected int z; ... } public class A2 extends A1 { protected int a; private int b; ... } public class A3 extends A2 { private int q; ... } a) Which of the following is true with respect to A1, A2 and A3? Group of answer choices A1 is a subclass of A2 and A2 is a subclass of A3 A3 is a subclass of A2 and A2 is a subclass of A1 A1 and A2 are both subclasses of A3 A2 and A3 are both subclasses of A1 A1, A2 and A3 are all…arrow_forward
- a c++ program in which class A is base class for class B. While Class C is derived from class B and class D is derived from class E. Provide explicit implementation of default constructors and destructors. Write a test program which initializes each class object and shows execution order of constructor and destructor by printing appropriate messages. Modify the above classes and provide overloaded constructor implementation for each class. (Note: Use base initialize for this purpose) Note: Solve as soon as possible use oop conceptsarrow_forwardGiven the following class declaration (with prototypes): class Carpet { private: double pricePerSqYd; public: Carpet(); void setPricePerYd(double p); void setDimensions(double l, double w); double getTotalPrice() const; }; Assume the class Carpet has been implemented. Assume the class Rectangle has been implemented. Rewrite the entire Carpet class declaration and add a member variable named size which is an instance of the Rectangle class.arrow_forwardAnalysis the following class definition and answer the following question. class Student{ private int id, age; protected float mark; int getAge (int a){ return a ; } protected void setMark (float m){ mark = m; } float result(){ return mark / 2; } } Which is the member variable of the class? a. setMark b. getAge c. result d. private e. agearrow_forward
- Program SpecificationUsing python, design a class named PersonData with the following member variables: lastName firstName address city state zip phone Write the appropriate accessor and mutator functions for these member variables. Next, design a class named CustomerData , which is derived from the PersonData class. The CustomerData class should have the following member variables: customerNumber mailingList The customerNumber variable will be used to hold a unique integer for each customer. The mailingList variable should be a bool . It will be set to true if the customer wishes to be on a mailing list, or false if the customer does not wish to be on a mail-ing list. Write appropriate accessor and mutator functions for these member variables. Next write a program which demonstrates an object of the CustomerData class in a program. Your program MUST use exception handling. You can choose how to implement the exception handling. Start your program with a welcome message Make sure…arrow_forwardPLZ help wiith the following: IN JAVA If an inner class contains non static members, then the class name must be modified by the keyword: Final Static Void Protectedarrow_forwardConsider the following class: 1.Write its default constructor 2.Write a code to declare an object from this class using the default constructor public class Dog { String name; String color; void barking() { } void hungry() { } void sleeping() { } }arrow_forward
- Q2: Consider the following statements: public class YClass { private int a; private int b; public void one() { } public void two(int x, int y); { } public YClass() { } } class XClass extends YClass { private int z; public void one() { } public XClass() { } } YClass yObject; XClass xObject; Write the definition of the default constructor of YClass so that the instance variables of YClass are initialized to 0. Write the definition of the default constructor of XClass so that the instance variables of XClass are initialized to 0. Write the definition of the method two of YClass so that the instance variable a is initialized to the value of the first parameter of two and the instance variable b is initialized to the value of the second parameter of two. please I want solution :(arrow_forward__________ is the default behavior when an object is assigned the value of another object of the same class.arrow_forwardDesign a class bookType that defines a book as a class. a. Each object of the class bookType will hold the following information about a book: title number of authors up to four authors publisher year published ISBN 13 (with dashes) price number of copies in stock (may be 0) b. Include the member functions to perform the various operations on objects of type bookType: Include individual get and set functions for all member variables. c. Add a member function to update the number of copies in stock. d. Add the appropriate constructors and a destructor (if one is needed). Ensure a default constructor is coded and the constructor initializes all data members. Remember, an array of classes uses a default constructor only. e. ALL member variables must be private and accessed through member functions. The main client program CANNOT access the variables directly. f. Ensure the class declaration and class implementation files are in separate header and code (.cpp) files. This assignment will…arrow_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:CengageC++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr