New member, first question

Hello! Let me start with this..I have absolutely no previous programming experience and have taken an introductory C++ class. I've had no problems with our previous topics, but this "class" thing has really thrown me for a loop. Here is the problem I am having. I need to write a boolean function to determine whether a "balloon" has popped. Here is the driver function:
/*******************************************
* Program 09 Sample Program
* Written by 06-Apr-2009
*******************************************/
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
#include "Balloon.h"
/*******************************************
* void main()
* Main driver routine
*******************************************/
void main()
{ string option;
float air;
class balloon b;
// Output title
cout << "Welcome to the Balloon Factory\n\n";
cout << fixed << setprecision(2);
// Main Loop
do {
// Get user option
cout << "Enter action (Add,Release,Quit): ";
cin >> option;
if(option=="Add" || option=="Release")
{ cout << "Enter amount of air: ";
cin >> air;
};
// Add air
if(option=="Add")
b.inflate(air);
// Release air
if(option=="Release")
b.deflate(air);
// Check for pop
if(b.pop())
cout << "Balloon Popped!" << endl;
// Display current values
cout << "Volume: " << b.volume() << endl;
cout << "Diameter: " << b.diameter() << endl;
cout << "Pressure: " << b.pressure() << endl;
cout << endl;
// End of loop
} while(option!="Quit" && !b.pop());
// Finished message
cout << "Thank you!\n";
}

And my header file:

class balloon
#define B 3.15;
#define MAX 100;
{public:
balloon(); //Constructs an empty balloon
void inflate(float); //Adds air to balloon
void deflate(float); //Removes air from balloon
bool pop(); //Checks to see if balloon popped
float volume(); //Returns volume of air in balloon
float pressure(); //Calculates pressure of air in balloon
float diameter(); //Calculates new diameter of balloon
private:
float vol; //Stores current air volume
bool popped; //Status of balloon
};

And, finally, my function file:

//Circle calculation file
#include<iostream>
#include<cmath>
using namespace std;
#include "Balloon.h"

/**********************
*Balloon constructor
*No air
**********************/
balloon::balloon()
{ vol = 0.0;
}
/*********************
*Add air function
*********************/
void balloon::inflate(float air)
{vol = air + vol;
}
/*********************
*Remove air function
*********************/
void balloon::deflate(float air)
{vol = vol - air;
}
/********************
*Balloon pop function
********************/
bool balloon::pop()
{if(vol<=MAX)
{popped = false;
return false;}
else
{popped = true;
return true;}
}


What I need to do is return either a true or false when "vol" has exceeded "MAX" and also store that information in a variable called "popped"(see my header file). But, my bool function gives me either an "overloaded function not found in" message if I try to pass in a variable(like (float vol)), or if I leave the "()" empty I get a bunch of "( missing before ; messages. Grrr!! Can you help me with this one?

If it helps you at all...here is a link to my assignment:

https://www.msu.edu/~bowmanm/230/Program09.doc

I think that the solution here is incredible simple...but I've spent way too much time staring at the screen with no solution. Thanks for the help!!

-Daren
Last edited on
The problem is in these two lines:
1
2
#define B 3.15;
#define MAX 100; 

Don't put a semicolon in a #define. They are just an automated copypaste, and they will copy in a ; where you don't want them.
main should always return int, never, ever void.
int main()//4 eva!!
Last edited on
Topic archived. No new replies allowed.