help with class

My goal is to design a class named Automobile that holds the vehicle identification number, make, model, and color of an automobile, that includes methods to set the values for each data field, and a method that displays all the values for each field. Also, to write the program that will use this class.

I'm having problems with the display module. I'm getting an error that says "class Automobile declarations type name is not allowed" with the "Automobile" of Automobile.getVIN along with each other display statement underlined.

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
83
84
85
86
87
88
#include <iostream>
#include <string>
using namespace std;

/* This program takes and displays information
belonging to the automobile class */

//declarations
class Automobile
{
public:
	void setVehicleVIN(string);
	void setVehicleMake(string);
	void setVehicleModel(string);
	void setVehicleColor(string);
	void display(string, string, string, string);
	string getVIN();
	string getMake();
	string getModel();
	string getColor();
private:
	string VehicleVIN;
	string VehicleMake;
	string VehicleModel;
	string VehicleColor;
};

		void Automobile::setVehicleVIN(string VIN) 
		{
			VehicleVIN = VIN;
			return;
		}
		void Automobile::setVehicleMake(string make) {
			VehicleMake = make;
		}
		void Automobile::setVehicleModel(string model) {
			VehicleModel = model;
		}
		void Automobile::setVehicleColor(string color){
			VehicleColor = color;
		}
		void Automobile::display(string, string, string, string)
		{
		}
		string Automobile::getVIN(){
			return VehicleVIN;
		}
		string Automobile::getMake(){
			return VehicleMake;
		}
		string Automobile::getModel(){
			return VehicleModel;
		}
		string Automobile::getColor(){
			return VehicleColor;
		}
		void display(string getVIN, string getMake, string getModel, string getColor)
		{
			cout << "Vehicle VIN number is " << Automobile.getVIN() << endl;
			cout << "Vehicle make is " << Automobile.getmake() << endl;
			cout << "Vehicle model is " << Automobile.getmodel() << endl;
			cout << "Vehicle color is " << Automobile.getcolor() << endl;
		}



int main()
{
	string VIN, make, model, color;
	
	cout<<"Enter Vehicle ID"<<endl;
	cin>>VIN;
	
	cout<<"Enter Vehicle make"<<endl;
	cin>>make;
	
	cout<<"Enter Vehicle Model"<<endl;
	cin>>model;
	
	cout<<"Enter Vehicle Color"<<endl;
	cin>>color;
	
	void display();
	
	system("pause");
}



Any help is very appreciated. Thank you for your time.
closed account (NA5N6Up4)
1
2
3
4
cout << "Vehicle VIN number is " << Automobile.getVIN() << endl;
cout << "Vehicle make is " << Automobile.getmake() << endl;
cout << "Vehicle model is " << Automobile.getmodel() << endl;
cout << "Vehicle color is " << Automobile.getcolor() << endl;


It should be :
1
2
3
4
cout << "Vehicle VIN number is " << getVIN() << endl;
cout << "Vehicle make is " << getmake() << endl;
cout << "Vehicle model is " << getmodel() << endl;
cout << "Vehicle color is " << getcolor() << endl;

Thank you for your reply.

After making that change I'm now getting errors stating "call of an object of a class type without appropriate operator() or conversion functions to pointer-to-function type"
Where are you getting this error? Your compiler should be telling you which line number is causing the error.

Note that at line 83, that's not how you call a function. What you've done there is declared a function, not called it.

Also, I don't see anywhere in your code where you call your setter methods, so you're never actually doing anything with the values the user types in.
Last edited on
Topic archived. No new replies allowed.