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 744349
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T08:58:05+00:00 2026-05-14T08:58:05+00:00

what am I doing wrong here? I keep on getting a compilation error when

  • 0

what am I doing wrong here? I keep on getting a compilation error when I try to run this in codelab (turings craft)

Instructions:

Write the implementation (.cpp file) of the GasTank class of the previous exercise. The full specification of the class is:
A data member named amount of type double.
A constructor that no parameters. The constructor initializes the data member amount to 0.
A function named addGas that accepts a parameter of type double . The value of the amount instance variable is increased by the value of the parameter.
A function named useGas that accepts a parameter of type double . The value of the amount data member is decreased by the value of the parameter.
A function named getGasLevel that accepts no parameters. getGasLevel returns the value of the amount data member.

class GasTank{
double amount;
GasTank();
void addGas(double);
void useGas(double);
double getGasLevel();};

GasTank::GasTank(){
amount=0;}
double GasTank::addGas(double a){
amount+=a;}
double GasTank::useGas(double a){
amount+=a;}
double GasTank::getGasLevel(){
return amount;}
  • 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-05-14T08:58:05+00:00Added an answer on May 14, 2026 at 8:58 am

    You listed both the class declaration and its function implementations. What part of code is in the header file, and what part of it is in the implementation file?

    Also, recall that for a class the default visibility is private. Therefore, all your functions are private — including the constructor! — so you can’t instantiate an object of the class. Try changing the visibility of the relevant functions to public.

    Make sure the function signatures in the class declaration and the class definition match. So, if you declare

    class GasTank {
        // ...
    public:
        void addGas(double);
        // ...
    };
    

    make sure you define

    void GasTank::addGas(double d)
    {
        // ...
    }
    

    and not

    double GasTank::addGas(double d)
    {
        // ...
    }
    

    One last thing: do indent your code properly. There’s then a higher chance you marker (and us) will be in a good mood while reading your code.

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

Sidebar

Ask A Question

Stats

  • Questions 516k
  • Answers 516k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Here's a way to do this on Linux outside of… May 16, 2026 at 6:43 pm
  • Editorial Team
    Editorial Team added an answer If you write an unmanaged program and use CreateProcess API… May 16, 2026 at 6:43 pm
  • Editorial Team
    Editorial Team added an answer Update 2022: Some options for you: Have your server look… May 16, 2026 at 6:43 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I don't understand what I'm doing wrong here ! I keep getting a Data
I keep getting this error: uninitialized constant GetxmlController::Xmlparse my code for the class looks
I cannot figure out what I am doing wrong here. The permissions for the
Someone has to be able to explain what I'm doing wrong here! I'm trying
What am I doing wrong here ? /* * Consider the following pseudo code
What am I doing wrong here?: <GridViewColumn> <GridViewColumn.CellTemplate> <DataTemplate> <Button> <Button.ToolTip> <TextBlock Text={Binding Path=Title,
I'm not sure what I'm doing wrong here, I have a file in lib/acts_as_votable.rb
Bit of a JavaScript newbie here - I am firing this basic bit of
I'm just getting started with MySql and need to run simple queries on the
I'm trying to get the text value of the select option here and i

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.