Hi,
Trying out an online tutorial, and then changing it to suit me.
I finally got through all the syntax issues, only to be greeted with a lovely Linker error at compile time.
Can anyone see why?
The Linker seems to think it has something to do with the printVector function.
I can't for the life of me see what is wrong.
#ifndef VECOBJ_H_INCLUDED
#define VECOBJ_H_INCLUDED
class Bunch
{
public:
// Default constructor
Bunch();
// Overload constructor
Bunch(int, int, int);
// Default destructor
~Bunch();
// Accessor functions
int getFirst();
// So that the outside program can access contents of 'first'
int getSecond();
// So that the outside program can access contents of 'second'
int getThird();
// So that the outside program can access contents of 'third'
private:
int first;
int second;
int third;
};
#endif // VECOBJ_H_INCLUDED
> void printVector(const vector<Bunch>&);
...
> void printVector(vector<Bunch>& newList)
Yes, you need to make your mind up as to whether the parameter is const or not.
It didn't like it when I changed *both* to type const (it then complained that the type return of my getFirst/getSecond/getThird.
I removed the const from both declaration and function and it worked!