Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

LNK 2019 and LNK 1120

dww1g11dww1g11 Posts: 1Member
I am new to c++ and am using visual 2010. I'm trying to get to grips with templates and have compiled the following code

1 #include "stdafx.h"
2
3 template
4 class Vcr {
5 int length; // number of entries
6 T* vr; // entries of vector
7 public:
8 template friend class Vcr;
9 Vcr(int, const T* const); // constructor
10 Vcr(int = 0, T = 0); // constructor
11 Vcr(const Vcr&); // copy of constructor
12 ~Vcr(){ delete[] vr;} // destructor
13
14 int size() const { return length; } // number of entries
15 Vcr& operator=(const Vcr&); // assignment
16 T& operator[](int i) { return vr[i]; } // subscripting
17 Vcr& operator+=(const Vcr&); // v += v2
18 T maxnorm() const; // maximum norm
19
20 template // dot product
21 friend S dot(const Vcr&, const Vcr&);
22
23 };
24
25 int _tmain(int argc, _TCHAR* argv[]) {
26
27 Vcr (20);
28 return 0;
29 }

When I build the code I get the following error messages

: error LNK2019: unresolved external symbol "public: __thiscall Vcr::Vcr(int,double)" (??0?$Vcr@N@@QAE@HN@Z) referenced in function _wmain

: fatal error LNK1120: 1 unresolved externals


Any help would be appreciated.
Sign In or Register to comment.