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

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 keep getting this error when trying to configure the upload directory with Apache
I keep getting an error with this source code. Does anyone know what im
I keep getting an error when I try to set my startDate and endDate.
I keep getting an error for this regular expression: ^((([1-9])|(1[0-2])):([0-5])(0|5)/s(A|P)M)$ It's supposed to be
I'm trying to use the jQuery grid. I keep getting this error at the
What am I doing wrong here folks? <?php include 'header.php'; /** * Display a
What am I doing wrong here? I'm trying to get started with jQuery UI
What am I doing wrong here: class Helo { // main: generate some simple

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.