Я пытаюсь реализовать класс PointArray, полученный из шаблона. Вот как выглядит мой файл ХПП для PointArray как:Ошибка LNK2019 при построении шаблона
#ifndef POINTARRAY_H
#define POINTARRAY_H
#include <iostream>
#include <sstream>
#include <stdio.h>
#include "Array.hpp"
using namespace Abhishek::CAD;
using namespace Abhishek::CONTAINERS;
namespace Abhishek
{
namespace CONTAINERS
{
class PointArray : public Array<Point>
{
public:
PointArray();//Default constrcutor.
PointArray(int size);//Constructor with size argument.
PointArray(const PointArray& arr);//Copy constructor.
~PointArray();//Destructor.
double Length() const;//Length function.
};
}
}
#endif
Мой каст выглядит следующим образом:
#include <iostream>
#include <sstream>
#include <stdio.h>
#include "PointArray.hpp"
using namespace Abhishek::CAD;
using namespace Abhishek::CONTAINERS;
namespace Abhishek
{
namespace CONTAINERS
{
//Default constructor.
PointArray::PointArray(): Array<Point>()
{
cout<<"Point arr default cons"<<endl;
}
//Constructor with size argument.
PointArray::PointArray(int size) : Array<Point>(size)
{
}
//Copy constructor.
PointArray::PointArray(const PointArray& arr) : Array<Point>(arr)
{
}
//destrcutor.
PointArray::~PointArray()
{
}
}
}
Я получаю ошибку LNK:
error LNK2019: unresolved external symbol "public: __thiscall Abhishek::CONTAINERS::Array<class Abhishek::CAD::Point>::Array<class Abhishek::CAD::Point>(void)" ([email protected]@[email protected]@@@[email protected]@@[email protected]) referenced in function "public: __thiscall Abhishek::CONTAINERS::PointArray::PointArray(void)" ([email protected]@[email protected]@[email protected])
1>PointArray.obj : error LNK2019: unresolved external symbol "public: __thiscall Abhishek::CONTAINERS::Array<class Abhishek::CAD::Point>::Array<class Abhishek::CAD::Point>(int)" ([email protected]@[email protected]@@@[email protected]@@[email protected]@Z) referenced in function "public: __thiscall Abhishek::CONTAINERS::PointArray::PointArray(int)" ([email protected]@[email protected]@[email protected]@Z)
1>PointArray.obj : error LNK2019: unresolved external symbol "public: __thiscall Abhishek::CONTAINERS::Array<class Abhishek::CAD::Point>::Array<class Abhishek::CAD::Point>(class Abhishek::CONTAINERS::Array<class Abhishek::CAD::Point> const &)" ([email protected]@[email protected]@@@[email protected]@@[email protected]@@Z) referenced in function "public: __thiscall Abhishek::CONTAINERS::PointArray::PointArray(class Abhishek::CONTAINERS::PointArray const &)" ([email protected]@[email protected]@[email protected]@@Z)
1>PointArray.obj : error LNK2019: unresolved external symbol "public: __thiscall Abhishek::CONTAINERS::Array<class Abhishek::CAD::Point>::~Array<class Abhishek::CAD::Point>(void)" ([email protected]@[email protected]@@@[email protected]@@[email protected]) referenced in function [email protected]@[email protected]@[email protected]$0
1>C:\Users\Rambo\Documents\Level 6\Section 4.2b\Exercise 3\Debug\Exercise 3.exe : fatal error LNK1120: 4 unresolved externals
Я не понимаю, почему это может должно быть. Я включил все соответствующие файлы заголовков и файлы CPP. Если кто-то может помочь, я буду очень благодарен.
Где находится класс 'Point'? – juanchopanza
Позвольте мне предположить: реализация шаблона 'Array' находится в« Array.cpp », а не в« Array.hpp »? – molbdnilo
[Что является нерешенным внешним и как его исправить? Ответ: реализация шаблонов не отображается] (http://stackoverflow.com/a/12574417/673730). –