Question
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: main.cpp: In function bool testPassed(): main.cpp:35:23: error: std::__cxx11::string {aka class std::__cxx11::basic_string
//Vehicle.h
#pragma once #ifndef VEHICLE_H #define VEHICLE_H #include
// 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
// 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
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 //Truck.h #pragma once //Truck.h #ifndef TRUCK_H #define TRUCK_H #include //Truck.cpp #include "stdafx.h" #include return out_stream; } //main.cpp #include "stdafx.h" #include 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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started