mercredi 23 octobre 2019

Friend function unable to determine type in parameter

In my vector.h header file I have:

template <typename T>
class Vector{
private:
    int sz:
    T* buf;
public:
//member functions all the way down
friend ostream& operator << (ostream & o, const Vector & v);
};

In my vector.cpp file I have this:

#include "vector.h"
using namespace std;
//member functions defined

std::ostream& operator << (std::ostream & o, const Vector & v){
 return o;
}

I am getting a compiler error stating that "Vector" is an unknown type name. Could anyone help me figure out why this is? I am not allowed to change the header file.

Aucun commentaire:

Enregistrer un commentaire