Classes

I am learning about classes and I don't know what this error means. Error:
Error 1 error C3867: 'Car::m_carMake': function call missing argument list; use '&Car::m_carMake' to create a pointer to member c:\users\george\documents\visual studio 2013\projects\chapter13\scratchpaper\main.cpp 40 1 Paper


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
#include <iostream>
#include <string>
using namespace std;


class Car
{
private:
	int yearModel, speed;
	string carMake;
public:
	int m_yearModel(){ return yearModel; }
	int m_speed(){ return speed; }
	string m_carMake(){ return carMake; }
	void m_accelerate(){ speed = +5; }
	void m_break(){ speed = -5; }
	Car(int, string);
	Car();
	~Car();
};
Car::Car(){}
Car::Car(int year, string Make)
{
	yearModel = year;
	carMake = Make;
	speed = 0;
}
Car::~Car(){}

int main()
{

	int y;
	string m;
	cout << " Enter the maker of the car." << endl;
	cin >> m;
	cout << "Enter the year the car was made." << endl;
	cin >> y;
	Car c_car(y, m);
	cout << c_car.m_carMake << endl;

return 0;

}
Last edited on
Only a small error, you're forgetting parenthesis.

m_carMake is the name of a member function, not a property.

Change line 40 to:
cout << c_car.m_carMake() << endl;

That should work unless I missed something else.
Last edited on
That you. that fixed it.
Topic archived. No new replies allowed.