Error C2679. Need help fixing it.

Hi! I'm trying to write a simple code where I test the inheritance of a class and two derived classes. I am a beginner and my professor wants to keep it simple. So no pointers or overloading. I'm not sure how to fix this error.
Oh the complete error is :
binary'>>' no operator found which takes a right hand operand of type 'overloaded - function' or there is no acceptable conversion.
I am getting the error on my couts. The main is just to test if the methods in my class works and the derived classes methods work.
I am running VS 2015 if that helps.
I'm not sure why its happening because I've written a similar program and it has compiled with no errors.

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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
//Program Name:Project 1_Program 1
//Programmer Name: Jasmine Brown 
//Description: test the inherintance of class Vehicle
//Date Created: 10/14/2015

#include <iostream>

using namespace std;

class Vehicle
{
public:
	void setAge(int a)
	{
		age = a;
	}
	void setPrice(float p)
	{
		price = p;
	}
	float getAge()
	{
		return age;
	}
	float getPrice()
	{
		return price;
	}

	Vehicle();
	~Vehicle();

protected:
	int age;
	float price;
};

Vehicle::Vehicle()
{
	age = 0;
	price = 0.0;
}

Vehicle::~Vehicle()
{
}

class Car : public Vehicle
{
	protected:

		bool RaceCarStatus;

	public:

		void setRaceCarStatus(bool r)
		{
			RaceCarStatus = r;
		}

		bool getRaceCarStatus()
		{
			return RaceCarStatus;
		}

		
		Car();
		~Car();

};

Car::Car()
{
	RaceCarStatus = false;
}

Car::~Car()
{
}

class Truck: public Vehicle
{
	protected:
		bool DieselTypeStatus;

	public:	
		void setDieselTypeStatus(bool d)
		{
			DieselTypeStatus = d;
		}

		bool getDieselTypeStatus()
		{
			return DieselTypeStatus;
		}

		Truck();
		~Truck();
};

Truck::Truck()
{
	DieselTypeStatus = false;
}

Truck::~Truck()
{
}

int main(void)
{

	Vehicle v1;
	
	cout << "Vehicle age?: ";
	cin >> v1.setAge;
	
	cout << "Vehicle price?: ";
	cin >> v1.setPrice;
	


	system("pause");
	return 0;
}


Help would be greatly appreciated.
Last edited on
Hi,

The setAge function is supposed to take an argument, you aren't providing it with one. Try creating another variable in main, get input for it, then call the function with that variable.

Good Luck :+)
@TheIdeasMan I did something like this and the error still will not go away
1
2
3
4
5
6
7
8
9
10
11
12
13
14
int main(void)
{

	Vehicle v1;
	int a1;
	
	cout << "What is the vehicles age?: ";
	cin >> v1.setAge(a1);
	


	system("pause");
	return 0;
}
Last edited on
Perhaps a refresher on function call syntax would help:
http://www.cplusplus.com/doc/tutorial/functions/
Sorry I called the function wrong. So this is it:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
int main(void)
{

	Vehicle v1,v2;
	int a1;
	
	cout << "What is the vehicles age?: ";
	cin >> a1;
	v1.setAge(a1);
	


	system("pause");
	return 0;
}

That fixed the problem. Thanks @TheIdeasMan and @LB
Topic archived. No new replies allowed.