Question

Getting the following errors and not sure why. My classes for Van are defined just like...

Getting the following errors and not sure why. My classes for Van are defined just like for everything else. Also not sure why I am getting the error "undeclared identifier" . Below are the errors when I try and build:

______________________________________________________________________________________

./vehicles.h:1:2: error: unterminated conditional directive
#ifndef VEHICLES_H
^
vehicles.cpp:33:44: error: member initializer 'verbose_' does not name a non-static data member or base class
: serialNumber_(0), passengerCapacity_(0), verbose_(false)
                                           ^~~~~~~~~~~~~~~
vehicles.cpp:36:10: error: out-of-line definition of 'Vehicle' does not match any declaration in 'Vehicle'
Vehicle::Vehicle( const char *serialNumber, unsigned int passengerCapacity, bool verbose )
         ^~~~~~~
vehicles.cpp:37:60: error: member initializer 'verbose_' does not name a non-static data member or base class
: serialNumber_(0), passengerCapacity_(passengerCapacity), verbose_(verbose)
                                                           ^~~~~~~~~~~~~~~~~
vehicles.cpp:39:5: error: use of undeclared identifier 'verbose_'; did you mean 'verbose'?
if (verbose_) std::cout << "Vehicle()\n";
    ^~~~~~~~
    verbose
vehicles.cpp:36:82: note: 'verbose' declared here
Vehicle::Vehicle( const char *serialNumber, unsigned int passengerCapacity, bool verbose )
                                                                                 ^
vehicles.cpp:51:5: error: use of undeclared identifier 'verbose_'
if (verbose_) std::cout << "~Vehicle()\n";
    ^
vehicles.cpp:82:6: error: use of undeclared identifier 'verbose_'
{if (verbose_)std::cout << "Car()\n"; }
     ^
vehicles.cpp:87:5: error: use of undeclared identifier 'verbose_'
if (verbose_) std::cout << "Car()\n";
    ^
vehicles.cpp:93:5: error: use of undeclared identifier 'verbose_'
if (verbose_) std::cout << "~Car()\n";
    ^
vehicles.cpp:103:6: error: use of undeclared identifier 'verbose_'
{if (verbose_)std::cout << "Truck()\n";}
     ^
vehicles.cpp:109:5: error: use of undeclared identifier 'verbose_'
if (verbose_) std::cout << "Truck()\n";
    ^
vehicles.cpp:121:5: error: use of undeclared identifier 'verbose_'
if (verbose_) std::cout << "~Truck()\n";
    ^
vehicles.cpp:145:1: error: use of undeclared identifier 'Van'
Van::Van()
^
vehicles.cpp:149:1: error: use of undeclared identifier 'Van'
Van::Van( const char *serialNumber, unsigned int passengerCapacity,
^
vehicles.cpp:157:1: error: use of undeclared identifier 'Van'
Van::~Van()
^
vehicles.cpp:157:7: error: expected the class name after '~' to name a destructor
Van::~Van()
      ^
vehicles.cpp:162:7: error: use of undeclared identifier 'Van'
float Van::LoadCapacity() const
      ^
vehicles.cpp:167:13: error: use of undeclared identifier 'Van'
const char *Van::ShortName() const
            ^
vehicles.cpp:172:1: error: use of undeclared identifier 'Tanker'
Tanker::Tanker()
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]    

_________________________________________________________________________________________

Here is my code:

(vehicles.h)

____________

#ifndef VEHICLES_H
#define VEHICLES_H

#include
#include

enum VehicleType { badSn, vehicle, car, truck, van, tanker, flatbed };

class Vehicle
{
public:
Vehicle(); // default constructor
Vehicle( const char *, unsigned int ); // 2-arg constructor
virtual ~Vehicle();
const char* SerialNumber() const; // returns serial number
unsigned int PassengerCapacity() const; //returns passenger capacity
virtual float LoadCapacity() const; // returns 0
virtual const char* ShortName() const; // returns "UNK"
virtual float Toll() const; // returns toll using fee schedule
static VehicleType SnDecode(const char* sn);
private:
char * serialNumber_;
unsigned int passengerCapacity_;
};

class Car : public Vehicle
{
public:
Car();
Car( const char *, unsigned int );
virtual ~Car();
const char* ShortName() const; // returns "CAR"
};

class Truck : public Vehicle
{
public:
Truck();
Truck( const char *, unsigned int, char * );
virtual ~Truck();
const char* ShortName() const; // returns "TRK"
float Toll() const; // returns toll using fee schedule
const char* DOTLicense() const; // returns the license no
virtual float LoadCapacity() const;
private:
char *DOTLicense_;
};                                

(vehicles.cpp)

______________

float Vehicle::LoadCapacity() const
{
return 0.0;
}

unsigned int Vehicle::PassengerCapacity() const
{
return passengerCapacity_;
}

const char *Vehicle::ShortName() const
{
return "UNK";
}

float Vehicle::Toll() const
{
return 2.00; // Non-Truck toll
}

Car::Car()
: Vehicle()
{if (verbose_)std::cout << "Car()\n"; }

Car::Car( const char *serialNumber, unsigned int passengerCapacity )
: Vehicle( serialNumber, passengerCapacity)
{
if (verbose_) std::cout << "Car()\n";

}

Car::~Car()
{
if (verbose_) std::cout << "~Car()\n";
}

const char *Car::ShortName() const
{
return "CAR";
}

Truck::Truck()
: Vehicle(), DOTLicense_(0)
{if (verbose_)std::cout << "Truck()\n";}
                                        

0 0
Add a comment Improve this question Transcribed image text
Request Professional Answer

Request Answer!

We need at least 10 more requests to produce the answer.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the answer will be notified once they are available.
Know the answer?
Add Answer to:
Getting the following errors and not sure why. My classes for Van are defined just like...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Similar Homework Help Questions
  • The code will not run and I get the following errors in Visual Studio. Please fix the errors. err...

    The code will not run and I get the following errors in Visual Studio. Please fix the errors. error C2079: 'inputFile' uses undefined class 'std::basic_ifstream<char,std::char_traits<char>>' cpp(32): error C2228: left of '.open' must have class/struct/union (32): note: type is 'int' ): error C2065: 'cout': undeclared identifier error C2065: 'cout': undeclared identifier error C2079: 'girlInputFile' uses undefined class 'std::basic_ifstream<char,std::char_traits<char>>' error C2440: 'initializing': cannot convert from 'const char [68]' to 'int' note: There is no context in which this conversion is possible error...

  • C++ edit: You start with the code given and then modify it so that it does...

    C++ edit: You start with the code given and then modify it so that it does what the following asks for. Create an EmployeeException class whose constructor receives a String that consists of an employee’s ID and pay rate. Modify the Employee class so that it has two more fields, idNum and hourlyWage. The Employee constructor requires values for both fields. Upon construction, throw an EmployeeException if the hourlyWage is less than $6.00 or over $50.00. Write a program that...

  • 4.a) 4.b> 4.c) C++ Programming Lab Exercise 09 Inheritance. Friend Functions, and Polymorphism (virtual functions) 4.a)...

    4.a) 4.b> 4.c) C++ Programming Lab Exercise 09 Inheritance. Friend Functions, and Polymorphism (virtual functions) 4.a) Run the following code and observe the output. #include <iostream> #include <string> using namespace std; class Vehicle public: void print() { cout << "Print: I am a vehicle. \n"; } void display() { cout << "Display: I am a vehicle. \n"; } }; class Car: public Vehicle { public: void print() { cout << "Print: I am a car.\n"; } void display() { cout...

  • My main() file does not call to the class created in a .hpp file. It comes...

    My main() file does not call to the class created in a .hpp file. It comes out with the error "undefined reference to "___" const. I want to solve this by only changing the main() .cpp file, not the .hpp file. .cpp file .hpp file Thank you! include <iostream> include <string> tinclude "CourseMember.hpp using namespace std int main0 CourseMember CourseMember(90, "Jeff", "Goldblum"): // initializing the constructor cout<< "Member ID is <<CourseMember.getID) << endl; 1/ calling getID) accessor cout <<"First Name...

  • I need to implement a program that requests a x,y point and the radius of a...

    I need to implement a program that requests a x,y point and the radius of a circle. then it figures out the area and circumference using an overloaded operation. The full instructions, what I have and the errors I have are below. A point in the x-y plane is represented by its x-coordinate and y-coordinate. Design a class, pointType, that can store and process a point in the x-y plane. You should then perform operations on the point, such as...

  • Can anyone help me fix this program to make sure use stack and use STL library...

    Can anyone help me fix this program to make sure use stack and use STL library to check the name1 and name2 is palindrome. Thank you stackPalindrome.h #ifndef_STACK_PALINDROME_H #define_STACK_PALINDROME_H template <class StackPalindrome> class StackPalindrome { public:    virtual bool isEmpty() const = 0;    virtual bool push(const ItemType& newEntry) = 0;    virtual bool pop() = 0;    virtual ItemType peek() const = 0; }; #endif stack.cpp #include<iostream> #include<string> #include<new> #include "stackPalindrome.h" using namespace std; template <class ItemType> class OurStack...

  • 2 The following code has some errors. Please point out and correct them (there might be...

    2 The following code has some errors. Please point out and correct them (there might be more than 1 errors). Note: the use of const data member increment and member function print. // This code has some errors. #include using namespace std; class Increment { public: Increment( int c = 0, int i = 0); void addIncrement() const { count -= increment }; void print() const; private: int count; const int increment; }; Increment::Increment(int c, int i) { cout =...

  • The following program contains the definition of a class called List, a class called Date and...

    The following program contains the definition of a class called List, a class called Date and a main program. Create a template out of the List class so that it can contain not just integers which is how it is now, but any data type, including user defined data types, such as objects of Date class. The main program is given so that you will know what to test your template with. It first creates a List of integers and...

  • c++ question 1. C++ string Class What does the output look like after executing the following...

    c++ question 1. C++ string Class What does the output look like after executing the following statements? std::string numstr = "12"; numstr += "3"; std::cout << numstr << '\n'; A. None of these. B. The snippet has syntax errors. C. 15 D.123 // 2. Let S be a class that allows integers to be stored in its objects like an array. For example, if obj is an object of S, one can write statements like obj[0] = 100; or int...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT