Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7817541
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T06:15:28+00:00 2026-06-02T06:15:28+00:00

I have this annoying error in my program. Vehicle is the Base class. Bicycle

  • 0

I have this annoying error in my program.

“Vehicle” is the Base class.
“Bicycle” extends this class.

#ifndef BICYCLE_H
#define BICYCLE_H

#include "Vehicle.h"

#include <string>
#include <iostream>
using namespace std;

//Template class which is derived from Vehicle
template<typename T>
class Bicycle: public Vehicle
{
public:
    Bicycle();
    Bicycle(int, int, string, int); 
    ~Bicycle();

    //Redefined functions inherited from Vehicle
    void move(int, int); // move to the requested x, y location divided by 2
    void set_capacity(int); // set the capacity value; can't be larger than 2

};

Above is the Bicycle.h file (I do not have .cpp file for this class)

#ifndef VEHICLE_H
#define VEHICLE_H

#include "PassengerException.h"

#include <string>
#include <iostream>
using namespace std;


//ADD LINE HERE TO MAKE IT A TEMPLATE CLASS
template<typename T>
class Vehicle
{
public:
    Vehicle(); //default contstructor
    Vehicle(int, int, string, int); // set the x, y, name, and capacity
    virtual ~Vehicle(); //destructor; should this be virtual or not???


    //Inheritance - question #1; create these functions here and in Bicycle     class
    string get_name(); // get the name of the vehicle
    void set_name(string); //set the name of the vehicle
    void print(); // std print function (GIVEN TO YOU)

    //Polymorphism - question #2
    virtual void move(int, int); // move to the requested x, y location
    virtual void set_capacity(int); // set the capacity value

    //Operator overloading - question #3
    Vehicle<T> operator+(Vehicle<T> &secondVehicle) const;

    //Exceptions - question #4
    T get_passenger(int) throw(PassengerException); // get the passenger at the specified index
    void add_passenger(T) throw(PassengerException); // add passenger and the current passenger index
    void remove_passenger() throw(PassengerException); // remove a passenger using current passenger index


protected:
    int x_pos;
    int y_pos;
    string name;
    int capacity;
    T *passengers;
    int current_passenger;
};

Above is the Vehicle.h file. I do not have .cpp for this either.

Also, what do the ifndef define endif mean? Do I have to use those? Are they required?

And, do their names have to be formatted like that?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T06:15:31+00:00Added an answer on June 2, 2026 at 6:15 am
    class Bicycle: public Vehicle
    

    Vehicle is a template, so you need this:

    class Bicycle: public Vehicle<T>
    

    The #ifndef and #define and #endif are called header guards and are used to prevent your header file from being included more than once, causing things (classes) to be declared more than once.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I find this syntax astoundingly annoying. Every time I rename my class, I have
I have been getting this annoying error/bug in Visual Studio 2008 quite a bit
This is probably the most annoying error I have ever encountered. When I go
OK, this is really annoying. I have the (almost) simplest class possible. Two files:
I have built a site using Django and I am receiving this annoying error
i have this annoying problem with my site where, when you click on a
I have this annoying method which pop up a MessageBox. So when I try
This is annoying - I know how I'd do it in web... I have
This might seems silly question but for me it is annoying. I have installed
I have somehow misconfigured fingers. This leads to a very annoying situation. I select

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.