Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I dont understand why is counting Car:: as extra qualificatons i thought it was

ID: 3731804 • Letter: I

Question

I dont understand why is counting Car:: as extra qualificatons i thought it was required?

having errors on a cpp and header file. these are the errors im getting :

g++ -c Car.cpp
In file included from Car.cpp:1:0:
Car.h:19:14: error: ‘srcLLA’ has not been declared
void SetLLA(srcLLA);
^
Car.cpp:4:1: error: extra qualification ‘Car::’ on member ‘Car’ [-fpermissive]
Car::Car()
^
Car.cpp:4:1: error: ‘Car::Car()’ cannot be overloaded
In file included from Car.cpp:1:0:
Car.h:15:2: error: with ‘Car::Car()’
Car();
^
Car.cpp:11:1: error: extra qualification ‘Car::’ on member ‘Car’ [-fpermissive]
Car::Car(const float * srcLLA)
^
Car.cpp:11:1: error: ‘Car::Car(const float*)’ cannot be overloaded
In file included from Car.cpp:1:0:
Car.h:16:2: error: with ‘Car::Car(const float*)’
Car(const float * srcLLA);
^
Car.cpp:19:1: error: extra qualification ‘Car::’ on member ‘Car’ [-fpermissive]
Car::Car(const Car& srcCar)
^
Car.cpp:19:1: error: ‘Car::Car(const Car&)’ cannot be overloaded
In file included from Car.cpp:1:0:
Car.h:17:2: error: with ‘Car::Car(const Car&)’
Car(const Car& srcCar);
^
Car.cpp:25:1: error: extra qualification ‘Car::’ on member ‘Car’ [-fpermissive]
Car::~Car()
^
Car.cpp:25:1: error: ‘Car::~Car()’ cannot be overloaded
In file included from Car.cpp:1:0:
Car.h:18:10: error: with ‘virtual Car::~Car()’
virtual ~Car();
^
Car.cpp:36:6: error: extra qualification ‘Car::’ on member ‘SetThrottle’ [-fpermissive]
void Car::SetThrottle(int srcThrottle)
^
Car.cpp:36:6: error: ‘void Car::SetThrottle(int)’ cannot be overloaded
In file included from Car.cpp:1:0:
Car.h:20:7: error: with ‘void Car::SetThrottle(int)’
void SetThrottle(int srcThrottle);
^
Car.cpp:50:5: error: extra qualification ‘Car::’ on member ‘GetThrottle’ [-fpermissive]
int Car::GetThrottle()
^
Car.cpp:50:5: error: ‘int Car::GetThrottle()’ cannot be overloaded
In file included from Car.cpp:1:0:
Car.h:21:6: error: with ‘int Car::GetThrottle()’
int GetThrottle();
^
Car.cpp:60:6: error: extra qualification ‘Car::’ on member ‘Drive’ [-fpermissive]
void Car::Drive(int srcThrottle)
^
Car.cpp:60:6: error: ‘void Car::Drive(int)’ cannot be overloaded
In file included from Car.cpp:1:0:
Car.h:22:7: error: with ‘void Car::Drive(int)’
void Drive(int srcThrottle);
^
Car.cpp:71:6: error: extra qualification ‘Car::’ on member ‘Serialize’ [-fpermissive]
void Car::Serialize(std::ostream& os)
^
Car.cpp:71:6: error: ‘void Car::Serialize(std::ostream&)’ cannot be overloaded
In file included from Car.cpp:1:0:
Car.h:32:15: error: with ‘virtual void Car::Serialize(std::ostream&)’
virtual void Serialize (std::ostream& os);
^
Car.cpp:91:6: error: extra qualification ‘Car::’ on member ‘Move’ [-fpermissive]
void Car::Move(const float * srcLLA)
^
Car.cpp:91:6: error: ‘void Car::Move(const float*)’ cannot be overloaded
In file included from Car.cpp:1:0:
Car.h:23:15: error: with ‘virtual void Car::Move(const float*)’
virtual void Move(const float * srcLLA);
^
Car.cpp:112:6: error: extra qualification ‘Car::’ on member ‘operator=’ [-fpermissive]
Car& Car::operator=(Car& srcCar)
^
Car.cpp:112:6: error: ‘Car& Car::operator=(Car&)’ cannot be overloaded
In file included from Car.cpp:1:0:
Car.h:24:7: error: with ‘Car& Car::operator=(Car&)’
Car& operator=(Car& srcCar);
^
Car.cpp:121:1: error: expected ‘;’ after class definition
}
^
Car.cpp: In constructor ‘Car::Car(const float*)’:
Car.cpp:13:14: error: invalid conversion from ‘const float*’ to ‘int’ [-fpermissive]
SetLLA(srcLLA);
^
In file included from Car.cpp:1:0:
Car.h:19:7: note: initializing argument 1 of ‘void Car::SetLLA(int)’
void SetLLA(srcLLA);
^

this is my header file:


#ifndef _CAR_H
#define _CAR_H
#include "Vehicle.h"

const int DFLT_THRTLE = 0;
class Car {
friend ostream& operator<<(ostream& os, Car& n_Car);
public:
Car();
Car(const float * srcLLA);
Car(const Car& srcCar);
virtual ~Car();
void SetLLA(srcLLA);
void SetThrottle(int srcThrottle);
int GetThrottle();
void Drive(int srcThrottle);
virtual void Move(const float * srcLLA);
Car& operator=(Car& srcCar);
protected:
float m_lla[MAX_SIZE];
private:
virtual void Serialize (std::ostream& os);
int m_throttle;


#endif

and my cpp file :

#include "Car.h"

//default constructor
Car::Car()
{
m_throttle = DFLT_THRTLE;
cout << "Car: Default-ctor" << endl;
}

//parameterized constructor
Car::Car(const float * srcLLA)
{
SetLLA(srcLLA);
SetThrottle(DFLT_THRTLE);
cout << "Car: Parametrized-ctor" << endl;
}

//copy constructor
Car::Car(const Car& srcCar)
{
this->SetThrottle(srcCar.m_throttle);
cout << "Car: Copy-ctor" << endl;
}
//virtual destructor
Car::~Car()
{
cout << "Car: Dtor" << endl;
}

/*
SetThrottle:
Set's the throttle member of the car class by assigning
the integer value passed in. If the value is less than zero than
the default throttle value is used.
*/
void Car::SetThrottle(int srcThrottle)
{
if(srcThrottle < 0)
{
cout << "Can't be less than 0, that's braking!" << endl;
m_throttle = DFLT_THRTLE;
}
m_throttle = srcThrottle;
}

/*
GetThrottle:
Returns the value of the throttle to the calling routine
*/
int Car::GetThrottle()
{
return m_throttle;
}

/*
Drive:
Makes the car go vroom vroom. In other words, it drives
at the speed passed in.
*/
void Car::Drive(int srcThrottle)
{
if(srcThrottle < DFLT_THRTLE)
{
cout << "Can't be negative. Locking your brakes!" << endl;
m_throttle = DFLT_THRTLE;
}
m_throttle = srcThrottle;
cout << "We're now driving!" << endl;
}

void Car::Serialize(std::ostream& os)
{
os << "Car @: [";
int i = 0;
while (i < 2)
{
os << m_lla[i++] << ", ";
}
++i;
os << m_lla[i] << "]";
os << "Throttle: " << m_throttle;
}

/*
Move:
Overrides the Pure virtual Vehicle::Move() function.
It then takes the new LLA location by address in order
for the car object to move there. It then calls drive
and passes the acceleration of 75 mph.
*/
void Car::Move(const float * srcLLA)
{
//Drive to this destination at 75 mph
cout << "Moving to destination: [";
int i = 0;
while (i < 2)
{
cout << srcLLA[i] << ", ";
++i;
}
cout << srcLLA[i] << "]" << endl;
Drive(75);
cout << "Car: DRIVE to destination, with throttle @75 " << endl;
}


/*
operator=:
Assign members values to the calling object based
ont he values of another Car object.
*/
Car& Car::operator=(Car& srcCar)
{
if(this != &srcCar) //parameter check
{
SetThrottle(srcCar.m_throttle);
}
cout << "Car: Assignment" << endl;
return *this;
}

Explanation / Answer

Hi, You have missed closing braket '}' in Car.h file:

#ifndef _CAR_H
#define _CAR_H
#include <iostream>
using namespace std;
//#include "Vehicle.h"

const int DFLT_THRTLE = 0;
class Car {
friend ostream& operator<<(ostream& os, Car& n_Car);
public:
Car();
Car(const float * srcLLA);
Car(const Car& srcCar);
virtual ~Car();
void SetThrottle(int srcThrottle);
int GetThrottle();
void Drive(int srcThrottle);
virtual void Move(const float * srcLLA);
Car& operator=(Car& srcCar);
protected:
float m_lla[MAX_SIZE];
private:
virtual void Serialize (std::ostream& os);
int m_throttle;
};


#endif

Please test now, it will work.