I'm getting an error i cannot figure. Here is my code
Header file
-------------------------------------------------------------------------------------------
Expand|Select|Wrap|Line Numbers
- #ifndef Clock_H
- #define Clock_H
- #include <vector>
- #include <list>
- class Clock {
- public:
- //Constructor
- Clock(int h, int s, int e);
- //Get the next and previous configs of the current config
- vector<vector<int> > getNeighborConfigs(vector<int> config);
- //Is the current Config a solution?
- bool isSolution(vector<int> sol);
- //Gets the goal config
- int getSolution();
- //Sets the current step # of the solution
- void setStep(int val);
- //Displays the solution
- void display(list<vector<int> > dList);
- private:
- int hours;
- int start;
- int end;
- int stepNumber;
- };
- #endif
- ------------------------------------------------------------------------------------------
- CPP file
- #include <vector>
- #include <list>
- #include <queue>
- #include <iostream>
- #include "Clock.h"
- /**
- * Constructor for Clock class that takes in the hours, start time
- * and goal time. Uses sub-object construction
- */
- Clock::Clock(int h, int s, int e) :
- hours(h), start(s), end(e) {
- }
- /**
- * Get the next and previous configs of the current config
- * Stores it in a vector of vector of ints
- */
- vector<vector<int> > Clock::getNeighborConfigs(vector<int> config) {
- vector<vector<int> > configs; //stores the next and previous configs
- vector<int> next; //stores the next config
- vector<int> previous; //stores the previous config
- int num1=(config.front() + 1)%hours;
- int num2=(config.front() -1)%hours;
- if(n1 == 0) {
- n1 = hours;
- }
- if(n2 == 0) {
- n2 = hours;
- }
- next.push_back(num1);
- previous.push_back(num2);
- configs.push_back(next);
- configs.push_back(previous);*/
- //return configs;*/
- }
- /**
- * Is the current Config a solution?
- */
- bool Clock::isSolution(vector<int> sol) {
- for(int i=0; i<sol.size(); i++) {
- if(sol[i]==end)
- return true;
- }
- return false;
- }
- /**
- * Gets the goal config
- */
- int Clock::getSolution() {
- return end;
- }
- /**
- * Sets the current step # of the solution
- */
- void Clock::setStep(int val) {
- stepNumber=val;
- }
- /**
- * Displays the solution
- */
- void Clock::display(list<vector<int> > dList) {
- cout << "Count: " << count << endl;
- cout << "The solution is: " << endl;
- while(!dList.empty()) {
- vector<int> vec = dList.front();
- cout << vec[0] << endl;
- dList.pop_front();
- cout << endl;
- }
- }
Expand|Select|Wrap|Line Numbers
- Clock.h:24: error: ISO C++ forbids declaration of vector with no type
- Clock.h:24: error: expected ; before < token
- Clock.h:27: error: vector has not been declared
- Clock.h:27: error: expected , or ... before < token
- Clock.h:36: error: list has not been declared
- Clock.h:36: error: expected , or ... before < token
- Clock.cpp:34: error: expected constructor, destructor, or type conversion before < token
Thanks