problem declaring a vector within a class

I'm trying to declare two vectors within the private section of a class "rover" I am working on.

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
#ifndef ROVER_H
#define ROVER_H              

class rover
{
public:
	// CONSTRUCTORS
	rover();
	//Default constructor
	// POSTCONDITION: The rover is initialized with default coordinates (0,0) heading 
	// North
	
	rover(double initial_x, double initial_y, char intitialHeading);
	//Default constructor
	// POSTCONDITION: The rover is initialized with coordinates heading specified
	// by the user
	
	// MODIFICATION MEMBER FUNCTIONS
	void move_forward(double meters);
	//Function to move the rover forward a max of 25 meters
	// POSTCONDITION: The rover has moved in the direction of its heading
	// by the specified number of meters
	
	void move_backward(double meters);
	//Function to move the rover in reverse a max of 4 meters
	// POSTCONDITION: The rover has moved in the opposite direction of its heading
	// by the specified number of meters

	void turn_right();
	//Function that turns the rover 90 degrees to the right
	// POSTCONDITION: The rover's heading has moved 1 direction clockwise

	void drill_core();
	//Function that drills a core at current location and stores the location
	//POSTCONDITION: A core has been drilled and its location has been stored


	// CONSTANT MEMBER FUNCTIONS
	void current_location() const;
	//Function to report the rovers location and heading
	// POSTCONDITION: The coordinates and heading are returned as an ordered
	// triple

	int core_quantity() const;
	//Function that reports the number of cores drilled
	//POSTCONDITION: the quantity of core samples has been outputed
	
	void core_report() const;
	//Function that reports quantity of cores drilled as well as their locations
	//POSTCONDITION:  All cores and their locations have been outputed
	
private:
	double x;
	double y;
	char heading;
	vector<double> core_x;
	vector<double> core_y;
	int quantity;
	
	//const double FORWARD_MAX = 25;
	//const double REVERSE_MAX = -4;
};

#endif 


Whenever I try to run this with my implementation file I get the following errors:

Error 1 error C2143: syntax error : missing ';' before '<'
Error 2 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
Error 3 error C2238: unexpected token(s) preceding ';'
Error 4 error C2143: syntax error : missing ';' before '<'
Error 5 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
Error 6 error C2238: unexpected token(s) preceding ';'
Error 7 error C2143: syntax error : missing ';' before '<'
Error 8 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
Error 9 error C2238: unexpected token(s) preceding ';'
Error 10 error C2143: syntax error : missing ';' before '<'
Error 11 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
Error 12 error C2238: unexpected token(s) preceding ';'
Error 13 error C2065: 'core_x' : undeclared identifier
Error 14 error C2228: left of '.pushback' must have class/struct/union
Error 15 error C2065: 'core_y' : undeclared identifier
Error 16 error C2228: left of '.pushback' must have class/struct/union

All of these seem to stem from the vectors. Can I not declare a vector there? Also, you can see where I commented out the two constants because they were giving me problems as well.

I've tried including #include <vector> at the top but it generates the same errors.

When I add namespace std it fixes the previous errors but gives me the following error on my implementation file where I try to pushback:

Error 1 error C2039: 'pushback' : is not a member of 'std::vector<_Ty>'
closed account (1yR4jE8b)
1. You need to #include <vector> and either use std::vector<double> to declare vectors or just using namespace std; //not really recommended for headers .

2. It's push_back not pushback.
You shouldn't have using namespace std; in a header file.
Topic archived. No new replies allowed.