What will the output be for the following code? #include #include #include using namespace std; class Student { private: string m_name; shared ptr m_pFriend; public: Student (string name) : m_name (name) { } void makeFriend (shared_ptr f) { m_pFriend=f; } }; void mystery (shared_ptr p) { cout « "ref count: " « p.use_count () « endl; p->makeFriend (p); weak ptr wps = p; auto p2 = wps.lock () ; cout « "ref count: " « p.use_count () « endl; int main () { auto ps (make_shared("Ellise")); cout <« "ref count: " <« ps.use_count () « endl; mystery (ps); cout << "ref count: « ps.use_count () « endl; return O;
Q: 2) You must implement the pieces of the below classes on the following pages. You only should…
A: Given: class Point {public:Point();Point(double, double);double getX() const;double getY()…
Q: Q3. Write a java program that creates a user-define class for objects of an Employee (name, age,…
A: First, we need to define the Employee class with name, age, and salary fields and then add a 3…
Q: Q2- A class name (Student ) contain the following information:- (Student- ID of type int, Full-name…
A: Create a class Declare data members as private Declare constructor, getters and setters as public
Q: Create a class called Student (Student.java). It should have the following private data members:…
A: Actually, java is an object oriented programing language. It is an platform independent.
Q: Write a class called Pet that contains an animal’s name, type, and weight. Include a default…
A: import java.util.*;import java.lang.*; public class Pet { private String name; private String…
Q: Part-1: Study the following method, then perform the required steps and answer the questions below:…
A: SOURCE CODE // Main classpublic class Main{ // swap method public static void swap(int num1 ,…
Q: Q4. Write a program which has a class called Area and appropriate member functions to get input from…
A: Default constructor: A constructor is a special method of the class. The name of the constructor is…
Q: TRICTLY USE TEMPLATE PROVIDED AT END OF QUESTION. FOLLOW WHAT IS GIVEN IN QUESTION…
A: Required: program in c++ and must match output as it is . ------------------------------------…
Q: Write the Out put of the following code and correct the errors: #include using namespace std;…
A: Please check the comments added below that will help to remove errors and successfully run the…
Q: It is a library service program to issue book based on ISBN and book title. Identify the code smells…
A: Consider the Borrower class.
Q: #include using namespace std; class Base { public: virtual void f() { coutf(); } A - Base B -…
A: #include<iostream> using namespace std; class Base { public: virtual void f() {…
Q: Create a class called Pizza (Pizza.java). It shoule private data members: String size: size of the…
A: GIVEN: Create a Java program with class Pizza having private member functions size, numOfToppings…
Q: Part A Write a class Bill containing the following attribute: V ID: The Bill number of type int V…
A: Solution: Java Program: import java.util.*; public class Bill { // Declare variables //…
Q: Suppose that a class is defined to represent a deck of cards or a player's hand in a card game. This…
A: ANSWER:-
Q: main() function is given below. Based on this function, your task is to write complete code required…
A: A main() function is given below. Based on this function, your task is to write complete code…
Q: We have noticed that the system floating point number will some times lose information. For this…
A: Actually c++ is a powerful general purpose language.
Q: In the following code: Character Skipper skip=new Character_Skipper(char ch); skip.start(ch); The…
A: Here in the given code, we are creating an object of class Character_Skipper. Now while creating an…
Q: With the coding below ,Complete the part labelled ‘//2 a) i’, write the constructor function that…
A: The question is writing C++ code for 2a)i and 2a)ii.
Q: Q 1: Access class members from the same package Note: ClassA and ClassB in this question are in the…
A: In order to create a variable that is not accessible outside class we must declare it as private. If…
Q: What is the output of the following code: class Mammal { // Some data members public: Mammal();…
A: Given data is shown below:
Q: A class Student can have three member variables: name, age, and an array of grades of two exams…
A: #include <iostream> using namespace std; template <typename T> class Student { private:…
Q: In this task, you are going to be implementing a sorted array of angle measurements modelled as…
A: The class contains two double variables. It consists of a default constructor, getter and setter…
Q: class A Q5: Correct the following code fragment and what will be the final results of the variable a…
A: Source Code #include <iostream> using namespace std; class A { protected: int…
Q: Use following main() to test your class. int main(){ Vehicle a,b("Honda","Civic",25000);…
A: In the given main module, we are creating two Vehicle instances a and b using default constructor…
Q: What is wrong with the following code? public class ClassB extends ClassA { public ClassB () { int…
A: A constructor in Java or a Java constructor is a basic term which is used to define a process which…
Q: What will the following program display? #include <iostream> using namespace std; class…
A:
Q: (d) Complete the following code by writing the constructor and toString method in Sub class to print…
A: Provided the Rewritten code for both of the above given questions where highlighted part represents…
Q: Q2- A class name (Student ) contain the following information:- (Student- ID of type int , Full-name…
A: /*C++ Program for student class*/ //include standard header#include <iostream>…
Q: reate a class called Student (Student.java). It should have the following private data members:…
A: The detailed description is provided for a java class named Student which is to be implemented as a…
Q: Q2) Write a Java code to satisfy the followings requirements: The class DrugStore has the private…
A: Solving the above problem is very easy with java here is how :- Create the private data members…
Q: Please Fix this program
A: Point p0(); // Calling Default Constructor This is incorrect way of making object of default…
Q: private String name; private int code; and following constructor: public Item(String n, int c) {…
A: Here have to determine correct option for given problem of java Language of constructor.
Q: 1 2 #include 3 using namespace std; 4 class Quad 6日{ private: double height; double base; 7 8 9 10…
A: A constructor is a special method of a class that is used for creating and initializing an object of…
Q: /Animal.cpp is the main function file of the Animal class //CSIS 112/B16 #include using namespace…
A: Actually, program is an executable software that runs on a computer.
Q: Assume class LinkedQueue has been deined using the implementation in your textbook that myQueue has…
A:
Q: Please, I want to modify the code so that the user can add the employee's name, number and…
A: Solution: Python Program: class Doctor: """Represents a Doctor""" def __init__(self, Id,…
Q: Study the following definition of class testType, and answer the question be class testType public:…
A: #include <bits/stdc++.h>using namespace std; class testype {public: void setdata(double f,…
Q: 6: Which of the following is a non-true statement(s)? click all apply A) In C++, friend is not a…
A: Given few statements about the C++ programing language and we need to tell which statement is not…
Q: Write a program which have a class named as “Student”, while the data members of the class are,…
A: Note:- we are allowed to answer only one question according to policy. char name[10], int age;…
Q: * Which among the following is not true ?for polymorphism Ease in readability of program O It is…
A: Which among the following is not true for polymorphism? Increases overhead of function definition…
Q: Question#01. Create a class Mixed to represent a mixed fraction having data members middle, upper,…
A: Swapping two numbers: The swapping or exchanging two numbers with the help of the third variable…
Q: Write a code which contains a class CBookList with Private members: CBook books, int ListID. A…
A: Solution: Given: The instruction given are Private members: CBook books, int ListID. A constructor,…
Q: Create a class called Complex for performing arithmetic with complex numbers.Write a program to test…
A: Program code: //Header file section #include<iostream> #include<stdio.h> using…
Q: Write a program in java a class Box having three private data members (width, depth, height) The…
A: File name: “Box.java” public class Box { private double width; private double depth;…
Q: Write a program which have a class named as “Student”, while the data members of the class are,…
A: Since you have posted multiple questions, we will solve the first question for you. If youwant any…
Q: Create a class called Student (Student.java). It should have the following private data members: …
A: The requirement is to write a Student class in Java language with given 3 data members and member…
Q: In C++ Create a class: “Prime” with private data members: upper_limit (int), lower_limit (int) and…
A: Input upper_limit and lower_limit from user and assign the larger number as upper_limit and smaller…
Q: Code a private method called gradeScale that takes in a parameter mark as a String. The mark should…
A: PROGRAM import java.util.Scanner;public class grade_cal{private static String gradeScale(String…
Q: The following declaration or code segment has errors. Locate as many as possible. template <class…
A: GIVEN: The following declaration or code segment has errors. Locate as many as possible. template…
Q: Q2: write a program to create the following classes and then find: 1-to initialize a new data called…
A: Answer : class Car { static int count=0;String name;float price;String color;int seats;Car(String…
Step by step
Solved in 3 steps with 1 images
- How would I fix this to get it looking like output #2? //Animal.cpp is the main function file of the Animal class//CSIS 112/B16 #include <iostream>using namespace std;//defining Animal classclass Animal {public://Name and age of classstring name;int age;//default contstructorAnimal() {name = "";age = 0;cout << "Invoking Animal 2 argument constructor?" << endl;}//virtual functionvirtual void move() {}//getter and setter functionsstring getName() {return name;}void setName(string n) {name = n;}int getAge() {return age;}void setAge(int a) {age = a;}};//Dog derives Animal publicallyclass Dog : public Animal {public://dogs constructorDog(string n, int a) {name = n;age = a;cout << "Invoking Dog constructor" << endl;}//implementing virtual functionvirtual void move() {cout << "I run" << endl;}};class Rabbit : public Animal {public:Rabbit(string n, int a) {name = n;age = a;cout << "Invoking Rabbit constructor," << endl;}~Rabbit() {cout…#c++# Write a program that inputs a line of text, replaces all punctuation marks with spaces. 2.Create a class called Complex for performing arithmetic with complex numbers. Write a program to test your class. Complex numbers have the form realPart + imaginaryPart * i where i is Use double variables to represent the private data of the class. Provide a constructor that enables an object of this class to be initialized when it’s declared. The constructor should contain default values in case no initializers are provided. Provide public member functions that perform the following tasks: Adding two Complex numbers: The real parts are added together and the imaginary parts are added together. Subtracting two Complex numbers: The real part of the right operand is subtracted from the real part of the left operand, and the imaginary part of the right operand is subtracted from the imaginary part of the left operand. Printing Complex numbers in the form (a, b), where a is the real…What is the output of given code? #include<iostream>using namespace std;class Base {public:Base(){ cout<<"Constructing Base \n"; }virtual~Base(){ cout<<"Destructing Base \n"; }};class Derived: public Base {public:Derived(){ cout<<"Constructing Derived \n"; }~Derived(){ cout<<"Destructing Derived \n"; }}; int main(void){Derived *d = new Derived();Base *b = d;delete b;return 0;}
- Question: 3Implement the design of the Student_Tutor class that inherit from Student class so that the following code generates the output below:Hint: Each room has a capacity of 2 Student tutors.class Student: def __init__(self,name,student_id): self.name = name self.student_id = student_id self.semester = "Spring 2022" def details(self): print("Name:",self.name) print("Student_ID:",self.student_id) print("Current Semester:",self.semester)# Write your code here:STs = []S1 = Student("Reem", 18101235)S1.details()print("1.======================================")ST1 = Student_Tutor("Moynul", 16107892, 35, "CSE110", "CSE111")ST2 = Student_Tutor("Priyo", 16107792, 25,"CSE320")ST3 = Student_Tutor("Ronok", 18207892, 36, "CSE110", "CSE111", "CSE221", "CSE220")ST4 = Student_Tutor("Zeba", 19307892, 48, "CSE110")STs.extend([ST1, ST2, ST3, ST4])print("2.======================================")for i in range(len(STs)): STs[i].details()…Write a Program to define a Mobile class, with member variables o String brand; o double price o String OS (make it Final). o Float memory 1. Make a default constructor, 2. Make a parameterized constructor. 3. Overload the above Constructor. 4. Provide getters and setters for data members. 5. Inside main, create an array of mobiles. 6. Take data from user and set the values for the mobiles in array (check for array out of bound exception). 7. At the end Print data of array using Loop. Programming language : JavaIn Kotlin, Use this Employee class: data class Employee(val name: String, val wage: Double, val hours: Double) and this list of Employees: val l: List = listOf(Employee("Bob", 34.33, 42.0), Employee ("Cathy", 27.33, 15.25), Employee("Carlos", 46.99, 38.75), Employee("Tomas", 49.66,28.45), Employee("Xavier", 34.56, 11.5)) a) Write a function called calcBracket that calculates an employee's tax withholding bracket this way: if the Employee's hourly wage is under 15 (in dollars per hour), the withholding bracket is 0; if the wage is at least $15 but under $25, the bracket is .15 (that is, 15%); if the wage is at least $25 but less than $35, the bracket is .25; if th wage is at least $35, the bracket is .35. Return the bracket. b) Write a function that l, takes a list of Employees and f, a function from Double to Double (don't write a call to calcBracket into this function - you will take it as a parameter called f and call f). This function returns a list of Pairs in which each…
- Implement the Rectangle class as discussed this week. Use the class declaration below. Your job is to implement the functions. Implement the missing functions yourself. class Rectangle{ private: double width; double length; char *name; void initName(char *); public://constructorsRectangle();Rectangle(double, double, char*);//destructor ~Rectangle(); void setWidth(double); void setLength(double); void setWidth(char *); void setLength(char *); void setName(char *); double getWidth() const; double getLength() const; void printName() const { cout << name; }}; A few notes on the functions: initName(char *): this is a private member function. It should be the only function which dynamically allocates a char array to hold the name. setName(char *): this is a public member function which changes the name of the rectangle to a new name. It does not dynamically allocate memory, it only changes name. Demonstrate your class works…Q No 3. #include <string> using namespace std; class Account { public: Account(string accountName, int initialBalance) { name=accountName; if (initialBalance > 0) { balance = initialBalance; } } void deposit(int depositAmount) { if (depositAmount > 0) { balance = balance + depositAmount; } } int getBalance() const { return balance; } void setName(string accountName) { name = accountName; } string getName() const { return name; } private: string name; int balance; }; Rewrite the following code in correct form. a) Assume the following prototype of destructor is declared in class Time: void ~Time(int); b) Assume the following prototype of constructor is declared in class Employee: int Employee(string, string);…With the coding below ,Complete the part labelled ‘//2 a) i’, write the constructor function that outputs “~~Building Created~~” and labelled //2 a) ii’, write the codes to define function findLargest(…). This function will receive an array of 5 Room objects and display the area width x length) of each object. The largest room area will be determined and displayed accordingly. #include <iostream> using namespace std; class Room { int width, length; public: // 2 a)to complete void setData (int L, int T) { width = L; length = T; } friend class Building; } ; class Building { string name; public: Building() { name = "Building"; cout<<"----Buiding name : "<<name<<"-------"<<endl; } // 2 a)to complete }; int main() { Building B1; Room r[5]; int i = 0, x, y; while( i < 5 ) { cout<<"Enter the tables' width and length :\n"; cin>>x>>y; r[i]. setData(x,y); i++; } B1.findLargest(r); return 0; }
- Can you help me with this problem please. Here is my code: #include <iostream> using namespace std; const double GALLONS_IN_A_CUBIC_FEET = 7.48; class swimmingPool { public: void set(double l = 0, double w = 0, double d = 0, double fi = 0, double fo = 0, double wInPool = 0); void setLength(double l); void setWidth(double w); void setDepth(double d); void setWaterFlowRateIn(double fi); void setWaterFlowRateOut(double fo); void addWater(double time, double fillRate); void drainWater(double time, double drainRate); double poolTotalWaterCapacity(); double getLength(); double getWidth(); double getDepth(); double getWaterFlowRateIn(); double getWaterFlowRateOut(); double getTotalWaterInPool(); int timeToFillThePool(); int timeToDrainThePool(); double waterNeededToFillThePool(); swimmingPool(double l = 0, double w = 0, double d = 0, double fi = 0, double fo = 0, double…Please, I want to modify the code so that the user can add the employee's name, number and specialization, and use for loob He must add more than one employee. When he finishes adding the employee’s data, he asks the user: Do you want 1-Print the data 2-Add a new employee 3-Exit class Doctor:"""Represents a Doctor""" #initializer with specialization default to "general"def __init__(self, Id, name, specialization="general"):#attributesself.Id = Idself.name = nameself.specialization = specialization.lower() #initializing salary to 25000, basic salaryself.salary = 25000 #incrementing salary based on specialization#if specialization is pediatric, increasing salary by 10%if specialization == "pediatric":self.salary += self.salary*10/100 #if specialization is dental, increasing salary by 15%elif specialization == "dental":self.salary += self.salary*15/100 #str() functiondef __str__(self):return (f"Id: {self.Id} \n"f"Name: {self.name} \n"f"Specialization: {self.specialization} \n"f"Salary:…Can you help me please: 2. Consider the following statements: class temporary { public: void set(string, double, double); void print(); double manipulate(); void get(string&, double&, double&); void setDescription(string); void setFirst(double); void setSecond(double); string getDescription() const; double getFirst()const; double getSecond()const; temporary(string = "", double = 0.0, double = 0.0); private: string description; double first; double second; }; Now answer the following questions: a. Write the definition of the member function set so that the instance variables are set according to the parameters. b. Write the definition of the member function manipulate that returns a decimal number as follows: If the value of description is "rectangle", it returns first * second; if the value of description is "circle", it returns the area of the circle with radius first; if the value of description is "sphere", it returns the volume of the sphere with radius first; if the…