Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ I'm almost done with my program, but I get this error. Anyone could help me? Here's the issue: main.cpp: In function bool testPassed(): main.cpp:35:23:

C++ I'm almost done with my program, but I get this error. Anyone could help me? Here's the issue: image text in transcribed main.cpp: In function bool testPassed(): main.cpp:35:23: error: std::__cxx11::string {aka class std::__cxx11::basic_string} has no member named getName if (car.getOwner().getName() == "Carl"){ ^~~~~~~ CODE:

//Vehicle.h

#pragma once #ifndef VEHICLE_H #define VEHICLE_H #include #include "Person.h" #include using namespace std; class Vehicle { public: //call the "Vehicle" Vehicle(); // Default constructor Vehicle(string the_name, string man_name, int num_cyl);

// Accessors //call the "getManufacturer()" function string getManufacturer() const; //call the "getOwner()" function string getOwner() const; //call the "getCylinders()" function int getCylinders() const; //call the "setManufacturer()" function

// Setters/mutators void setManufacturer(string man_name); //call the "setOwner" function void setOwner(Person owner); //call the "setCylinders" function void setCylinders(int num_cyl);

//call the friend function: Overload the

//Vehicle.cpp

// vehicle.cpp : Defines the entry point for the console application. //

#include "stdafx.h" #include #include "Vehicle.h" #include using namespace std;

// Default constructor: initialize the manufacture's name to "none", // number of cylinders to 4, and the owner to a default Person Vehicle::Vehicle() { man_name = "none"; num_cyl = 4; Person p; // Calls default constructor of Person class owner = p; } Vehicle::Vehicle(string the_name, string man_name, int num_cyl) :owner(the_name) { this->man_name = man_name; this->num_cyl = num_cyl; } string Vehicle::getManufacturer() const { return man_name; } string Vehicle::getOwner() const { return owner.getName(); } int Vehicle::getCylinders() const { return num_cyl; } void Vehicle::setManufacturer(string man_name) { this->man_name = man_name; } void Vehicle::setOwner(Person owner) { this->owner = owner; } void Vehicle::setCylinders(int num_cyl) { this->num_cyl = num_cyl; } ostream& operator

//Person.h

#pragma once #ifndef PERSON_H #define PERSON_H

#include #include

using namespace std;

class Person { public: Person(); Person(string the_name); string getName() const; void setName(string name); friend ostream& operator

//Person.cpp

#include "stdafx.h" #include #include #include "Person.h" using namespace std; Person::Person() { name = "none"; } Person::Person(string the_name) { name = the_name; } string Person::getName() const { return name; } void Person::setName(string name) { this->name = name; } ostream& operator

//Truck.h

#pragma once //Truck.h #ifndef TRUCK_H #define TRUCK_H #include #include #include "Vehicle.h" using namespace std; class Truck :public Vehicle { public: Truck(); Truck(string the_name, string man_name, int num_cyl, double load, int towing); double getLoad() const; int getTowing() const; void setLoad(double load); void setTowing(int towing); friend ostream& operator

//Truck.cpp

#include "stdafx.h" #include #include #include "Person.h" #include "Vehicle.h" #include "Truck.h" using namespace std; Truck::Truck() :v("none", "none", 4) { } Truck::Truck(string the_name, string man_name, int num_cyl, double load, int towing) : v(the_name, man_name, num_cyl) { this->load = load; this->towing = towing; } double Truck::getLoad() const { return load; } int Truck::getTowing() const { return towing; } void Truck::setLoad(double load) { this->load = load; } void Truck::setTowing(int towing) { this->towing = towing; } ostream& operator

return out_stream; }

//main.cpp

#include "stdafx.h" #include #include "Person.h" #include "Truck.h" #include "Vehicle.h" using namespace std;

int main() { // Test case 1: Create a Person objectwith name Carl Person a("Carl"); cout

// Create a Vehicle object with owner name = "Berk" Vehicle b("Berk", "Honda", 3); cout

// Gets the name of the person using getName //function in background cout

Truck c("Berk", "Honda", 3, 3.3, 5); cout Latest submission 1:52 AM on 04/02/18 Total score: 4 5 Only show failing tests Download this submission 1: Unit test A Test that calls setManufacturer on Vehicle object with value "Ford" and tests with getManufacturer. 2: Unit test Test that calls setCylinders on Vehicle object with value 4 and tests with getCylinders 3: Unit test A Test that calls setOwner on Vehicle object with a Person object with name of "Carl" and tests with getName Compilation failed in.cpp: In function 'bool testPassed()': in.cpp:35:23: error: 'std:: cxx11::string laka class std: cxx11::b Compilation failed if (car.getowner ).getName )"Carl") 4: Unit test A Test that calls setTowing on a Truck object with value 8 and tests with getTowing 5: Unit test A Test that calls setLoad on a Truck object with value 12 and tests with getLoad

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

MongoDB Applied Design Patterns Practical Use Cases With The Leading NoSQL Database

Authors: Rick Copeland

1st Edition

1449340040, 978-1449340049

More Books

Students also viewed these Databases questions