I have the following in my Puzzle.h
class Puzzle
{
private:
vector<int> puzzle;
public:
Puzzle() : puzzle (16) {}
bool isSolved();
void shuffle(vector<int>& );
};
and then my Puzzle.cpp looks like:
Puzzle::Puzzle()
{
// Initialize the puzzle (0,1,2,3,...,14,15)
for(int i = 0; i <= puzzle.size(); i++)
{
puzzle[i] = i;
}
}
// ... other methods
Am I using the initializer list wrong in my header file? I would like to define a vector of ints and initialize its size to that of 16. How should I do this?
G++ Output:
Puzzle.cpp:16: error: expected unqualified-id before ')' token
Puzzle.cpp: In constructor `Puzzle::Puzzle()':
Puzzle.cpp:16: error: expected `)' at end of input
Puzzle.cpp:16: error: expected `{' at end of input
Puzzle.cpp: At global scope:
Puzzle.cpp:24: error: redefinition of `Puzzle::Puzzle()'
Puzzle.cpp:16: error: `Puzzle::Puzzle()' previously defined here