Help with private/public variables

Not sure what to do with this. Says the variable "Rocket" does not refer to a value. I'm pretty lost right now any help would be appreciated.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#include <iostream>
#include <math.h>
#include <cstdlib>
using namespace std;

class Rocket
{
public:
    Rocket() {}
    Rocket(double, double, double, double, double);
    double velocity(double, double, double, double, double) const;
    double altitude(double, double) const;
private:
    double rocketmass;
    double enginemass;
    double propmass;
    double thrust;
    double burn;
};

Rocket :: Rocket(double rocketm, double rocketengine, double rocektprop, double rocketthrust, double rocketburn)
{
    rocketmass = rocketm;
    enginemass = rocketengine;
    propmass = rocektprop;
    thrust = rocketthrust;
    burn = rocketburn;
    
}

double Rocket :: velocity(double thrust, double rocketmass, double enginemass, double propmass, double burn)const
{
    double acceleration;
    double averagemass;
    
    averagemass = ((rocketmass + enginemass + propmass) + (rocketmass + enginemass)) / 2;
    acceleration = thrust / averagemass;
    return(acceleration * burn);
}

double Rocket:: altitude(double burn, double acceleration)const
{
    return (.5 * acceleration * pow(burn, 2));
}

// Main Program
int main( )
{
	// Variable Declarations
	char answer;
    double rocketmass;
    double enginemass;
    double propmass;
    double thrust;
    double burn;
    
	//
    do{
	cout << "Enter the mass of the rocket: ";
    cin >> rocketmass;
    cout << "Enter the mass of the engine: ";
    cin >> enginemass;
    cout << "Enter the mass of the propellant: ";
    cin >> propmass;
    cout << "Enter the average thrust of the engine: ";
    cin >> thrust;
    cout << "Enter the burn duration of the engine: ";
    cin >> burn;
    cout << endl;
    
    
        
    cout << "The rockets maximum velocity is " << Rocket.velocity << endl;
    cout << "The rockets maximum altitude is " << Rocket.altitude << endl;
    cout << "Would you like to run the program again (Y or N)? ";
    cin >> answer;
    }while(answer == 'Y');
	//
	cout << "\n\nEnd Program.\n";
    
	return 0;
}
In function main you don't have a Rocket object. You need to define one, say on line 71 Rocket myRocket=Rocket(rocketmass,enginemass,propmass,thrust,burn);
I don't see why you would define the velocity or altitude with any parameters. You can calculate those from the private variables. Also, when you call those functions on line 74 and 75, they are functions, not public member variables, so you must call them as cout << "The rockets maximum velocity is " << myRocket.velocity(......) << endl; where the dots are the variables (or nothing if you listen to my previous advice). But you still need the parantheses
Ok but when i get rid of the parameters on velocity or altitude it gives me an out-of-line definition error. Am I supposed to get rid of lines 31-44? Then replace that with something else?
Sorry but im new to using objects
Nevermind, thats all I needed! Thanks for the help I appreciate it.
Topic archived. No new replies allowed.