Наши проекты:
Журнал · Discuz!ML · Wiki · DRKB · Помощь проекту |
||
ПРАВИЛА | FAQ | Помощь | Поиск | Участники | Календарь | Избранное | RSS |
[18.221.187.121] |
|
Сообщ.
#1
,
|
|
|
Здравствуйте,
пишу шаблон и столкнулся с проблемой линковки Цитата Linking... Main.obj : error LNK2001: unresolved external symbol "public: __thiscall Queue<int>::~Queue<int>(void)" (??1?$Queue@H@@QAE@XZ) Main.obj : error LNK2001: unresolved external symbol "public: __thiscall Queue<int>::Queue<int>(int)" (??0?$Queue@H@@QAE@H@Z) Debug/templat.exe : fatal error LNK1120: 2 unresolved externals Реализовал шаблон в cpp файле (пробовал также все сделать в одном h файле - эффект тот же). Сделаны конструктор и деструктор и все равно линкер ругается этой ошибкой. Вроде как это значит, что функция объявлена, но не реализована, но она у меня есть! Пробовал в Visual Studio c++ 6, Studio 2013 и 2017 В чем может быть проблема? Заранее спасибо. Main.cpp #include "queue.h" int main() { Queue <int> a(10); return 0; } queue.h template <class Data> class Queue { public: //êîíñòðóêòîðû Queue(); Queue(int number); Queue(Queue &obj); bool IsEmpty(); // ïðîâåðêà, ïóñòàÿ ëè î÷åðåäü. int GetBuffer(Queue obj); int GetBegin(); int GetEnd(); int GetCountElements(); int GetCurrentCount(); //ïåðåãðóæåííûå îïåðàòîðû Queue& operator = (const Queue &obj); // Queue& operator + (const Data &obj); Data operator - (); //äåñòðóêòîð ~Queue(); protected: int begin, // íà÷àëî î÷åðåäè end; // êîíåö î÷åðåäè int elemCT; //êîë-âî ýë-òîâ â äàííûé ìîìåíò const int maxsize; // ðàçìåð î÷åðåäè Data* queue; }; queue.cpp #include "queue.h" #include <string.h> template <class Data> Queue<Data>::Queue() { }; template <class Data> Queue<Data>::Queue<Data>(int number) { maxsize = number; queue = new* Data[number]; begin = 0; end = 0; elemCT = 0; }; template <class Data> Queue<Data>::Queue(Queue<Data> &obj) { maxsize = obj.GetCountElements(); obj.GetPointers(begin, end); elemCT = obj.GetCurrentCount(); queue = new* Data[maxsize]; obj.GetBuffer(queue); } //äåñòðóêòîð template <class Data> Queue<Data>::~Queue() { if (queue) delete[] queue; } //îïåðàòîð ïðèñâàèâàíèÿ(êîïèðîâàíèÿ) template <class Data> Queue<Data>& Queue<Data>::operator = (const Queue<Data> &obj) { maxsize = obj.maxsize; begin = obj.begin; end = obj.end; elemCT = obj.elemCT; memcpy(this->queue, obj.queue, sizeof(Data)*maxsize); return *this; } template <class Data> int Queue<Data>::GetBuffer(Queue<Data> obj) { memcpy(obj, this->queue, sizeof(Data)*maxsize) return 0; } template <class Data> int Queue<Data>::GetBegin() { return this->begin; } template <class Data> int Queue<Data>::GetEnd() { return this->end; } template <class Data> int Queue<Data>::GetCountElements() { return this->maxsize; } template <class Data> int Queue<Data>::GetCurrentCount() { return this->elemCT; } template <class Data> bool Queue<Data>::IsEmpty() { if (this->elemCT) return true; else return false; } template <class Data> Queue<Data>& Queue<Data>::operator + (const Data &obj) { if (elemCT < maxsize) { queue[elemCT] = obj; elemCT++; end++; } else { memcpy(queue[0], queue[1], sizeof(Data)*(elemCT - 1)); elemCT = maxsize; queue[maxsize - 1] = obj; } return *this; } template <class Data> Data Queue<Data>::operator - () { Data temp; temp = queue[0]; memcpy(queue[0], queue[1], sizeof(Data)*(elemCT - 1)); elemCT--; end--; return temp; } |
Сообщ.
#2
,
|
|
|
Цитата VictorSh @ В чем может быть проблема? Заранее спасибо. Все шабонные функции должны бать в h-файлах. Перенеси содержимое queue.cpp в queue.h |
Сообщ.
#3
,
|
|
|
Цитата VictorSh @ Вам надо все содержимое queue.cpp перенести в queue.h Когда компилятор обрабатывает ваш queue.cpp он понятия не имеет, для каких Data этот шаблон будет использоваться и никакого кода не генерит. Когда он обрабатывает ваш main.cpp - он не имеет реализации шаблона и поэтому думает, что реализация функций-членов queue<int> у вас где-то явно присутствует. А ее нет. В чем может быть проблема? |
Сообщ.
#4
,
|
|
|
Цитата Олег М @ Перенеси содержимое queue.cpp в queue.h Да, переносил, не помогло |
Сообщ.
#5
,
|
|
|
Цитата VictorSh @ Да, переносил, не помогло Покажи, как перенёс и ошибки |
Сообщ.
#6
,
|
|
|
Цитата Олег М @ Покажи, как перенёс и ошибки Файл main.cpp #include "queue.h" int main() { Queue <int> a(10); return 0; } Файл queue.h #include <string.h> template <class Data> class Queue { public: //êîíñòðóêòîðû Queue(); Queue(int number); Queue(Queue &obj); bool IsEmpty(); // ïðîâåðêà, ïóñòàÿ ëè î÷åðåäü. int GetBuffer(Queue obj); int GetBegin(); int GetEnd(); int GetCountElements(); int GetCurrentCount(); //ïåðåãðóæåííûå îïåðàòîðû Queue& operator = (const Queue &obj); // Queue& operator + (const Data &obj); Data operator - (); //äåñòðóêòîð ~Queue(); protected: int begin, // íà÷àëî î÷åðåäè end; // êîíåö î÷åðåäè int elemCT; //êîë-âî ýë-òîâ â äàííûé ìîìåíò const int maxsize; // ðàçìåð î÷åðåäè Data* queue; }; template <class Data> Queue<Data>::Queue() { }; template <class Data> Queue<Data>::Queue<Data>(int number) { maxsize = number; queue = new* Data[number]; begin = 0; end = 0; elemCT = 0; }; template <class Data> Queue<Data>::Queue(Queue<Data> &obj) { maxsize = obj.GetCountElements(); obj.GetPointers(begin, end); elemCT = obj.GetCurrentCount(); queue = new* Data[maxsize]; obj.GetBuffer(queue); } //äåñòðóêòîð template <class Data> Queue<Data>::~Queue() { if (queue) delete[] queue; } //îïåðàòîð ïðèñâàèâàíèÿ(êîïèðîâàíèÿ) template <class Data> Queue<Data>& Queue<Data>::operator = (const Queue<Data> &obj) { maxsize = obj.maxsize; begin = obj.begin; end = obj.end; elemCT = obj.elemCT; memcpy(this->queue, obj.queue, sizeof(Data)*maxsize); return *this; } template <class Data> int Queue<Data>::GetBuffer(Queue<Data> obj) { memcpy(obj, this->queue, sizeof(Data)*maxsize) return 0; } template <class Data> int Queue<Data>::GetBegin() { return this->begin; } template <class Data> int Queue<Data>::GetEnd() { return this->end; } template <class Data> int Queue<Data>::GetCountElements() { return this->maxsize; } template <class Data> int Queue<Data>::GetCurrentCount() { return this->elemCT; } template <class Data> bool Queue<Data>::IsEmpty() { if (this->elemCT) return true; else return false; } template <class Data> Queue<Data>& Queue<Data>::operator + (const Data &obj) { if (elemCT < maxsize) { queue[elemCT] = obj; elemCT++; end++; } else { memcpy(queue[0], queue[1], sizeof(Data)*(elemCT - 1)); elemCT = maxsize; queue[maxsize - 1] = obj; } return *this; } template <class Data> Data Queue<Data>::operator - () { Data temp; temp = queue[0]; memcpy(queue[0], queue[1], sizeof(Data)*(elemCT - 1)); elemCT--; end--; return temp; } Вывод компилятора: --------------------Configuration: templat - Win32 Debug-------------------- Compiling... Main.cpp d:\programming\templat\queue.h(40) : error C2758: 'maxsize' : must be initialized in constructor base/member initializer list d:\programming\templat\queue.h(30) : see declaration of 'maxsize' D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(41) : error C2166: l-value specifies const object D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(42) : error C2059: syntax error : '*' D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(46) : error C2143: syntax error : missing ';' before '}' D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(46) : error C2143: syntax error : missing ';' before '}' D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(46) : error C2143: syntax error : missing ';' before '}' D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(46) : error C2143: syntax error : missing ';' before '}' D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(46) : error C2143: syntax error : missing ';' before '}' D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(46) : error C2143: syntax error : missing ';' before '}' D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(46) : error C2143: syntax error : missing ';' before '}' D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(46) : error C2143: syntax error : missing ';' before '}' D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(46) : error C2143: syntax error : missing ';' before '}' D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(46) : error C2143: syntax error : missing ';' before '}' D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(46) : error C2143: syntax error : missing ';' before '}' D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(46) : error C2143: syntax error : missing ';' before '}' D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(46) : error C2143: syntax error : missing ';' before '}' D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(46) : error C2143: syntax error : missing ';' before '}' D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(46) : error C2143: syntax error : missing ';' before '}' D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(46) : error C2143: syntax error : missing ';' before '}' D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(46) : error C2143: syntax error : missing ';' before '}' D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(46) : error C2143: syntax error : missing ';' before '}' D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(46) : error C2143: syntax error : missing ';' before '}' D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(46) : error C2143: syntax error : missing ';' before '}' D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(46) : error C2143: syntax error : missing ';' before '}' D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(46) : error C2143: syntax error : missing ';' before '}' D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(46) : error C2143: syntax error : missing ';' before '}' D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(46) : error C2143: syntax error : missing ';' before '}' D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(46) : error C2143: syntax error : missing ';' before '}' D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(46) : error C2143: syntax error : missing ';' before '}' D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(46) : error C2143: syntax error : missing ';' before '}' D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(46) : error C2143: syntax error : missing ';' before '}' D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(46) : error C2143: syntax error : missing ';' before '}' D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(46) : error C2143: syntax error : missing ';' before '}' D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(46) : error C2143: syntax error : missing ';' before '}' D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(46) : error C2143: syntax error : missing ';' before '}' D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(46) : error C2143: syntax error : missing ';' before '}' D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(46) : error C2143: syntax error : missing ';' before '}' D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(46) : error C2143: syntax error : missing ';' before '}' D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(46) : error C2143: syntax error : missing ';' before '}' D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(46) : error C2143: syntax error : missing ';' before '}' D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(46) : error C2143: syntax error : missing ';' before '}' D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(46) : error C2143: syntax error : missing ';' before '}' D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(46) : error C2143: syntax error : missing ';' before '}' D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(46) : error C2143: syntax error : missing ';' before '}' D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(46) : error C2143: syntax error : missing ';' before '}' D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(46) : error C2143: syntax error : missing ';' before '}' D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(46) : error C2143: syntax error : missing ';' before '}' D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(46) : error C2143: syntax error : missing ';' before '}' D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(46) : error C2143: syntax error : missing ';' before '}' D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(46) : error C2143: syntax error : missing ';' before '}' D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(46) : error C2143: syntax error : missing ';' before '}' D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(46) : error C2143: syntax error : missing ';' before '}' D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(46) : error C2143: syntax error : missing ';' before '}' D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(46) : error C2143: syntax error : missing ';' before '}' D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(46) : error C2143: syntax error : missing ';' before '}' D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(46) : error C2143: syntax error : missing ';' before '}' D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(46) : error C2143: syntax error : missing ';' before '}' D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(46) : error C2143: syntax error : missing ';' before '}' D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(46) : error C2143: syntax error : missing ';' before '}' D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(46) : error C2143: syntax error : missing ';' before '}' D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(46) : error C2143: syntax error : missing ';' before '}' D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(46) : error C2143: syntax error : missing ';' before '}' D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(46) : error C2143: syntax error : missing ';' before '}' D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(46) : error C2143: syntax error : missing ';' before '}' D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(46) : error C2143: syntax error : missing ';' before '}' D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(46) : error C2143: syntax error : missing ';' before '}' D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(46) : error C2143: syntax error : missing ';' before '}' D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(46) : error C2143: syntax error : missing ';' before '}' D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(46) : error C2143: syntax error : missing ';' before '}' D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(46) : error C2143: syntax error : missing ';' before '}' D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(46) : error C2143: syntax error : missing ';' before '}' D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(46) : error C2143: syntax error : missing ';' before '}' D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(46) : error C2143: syntax error : missing ';' before '}' D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(46) : error C2143: syntax error : missing ';' before '}' D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(46) : error C2143: syntax error : missing ';' before '}' D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(46) : error C2143: syntax error : missing ';' before '}' D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(46) : error C2143: syntax error : missing ';' before '}' D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(46) : error C2143: syntax error : missing ';' before '}' D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(46) : error C2143: syntax error : missing ';' before '}' D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(46) : error C2143: syntax error : missing ';' before '}' D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(46) : error C2143: syntax error : missing ';' before '}' D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(46) : error C2143: syntax error : missing ';' before '}' D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(46) : error C2143: syntax error : missing ';' before '}' D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(46) : error C2143: syntax error : missing ';' before '}' D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(46) : error C2143: syntax error : missing ';' before '}' D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(46) : error C2143: syntax error : missing ';' before '}' D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(46) : error C2143: syntax error : missing ';' before '}' D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(46) : error C2143: syntax error : missing ';' before '}' D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(46) : error C2143: syntax error : missing ';' before '}' D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(46) : error C2143: syntax error : missing ';' before '}' D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(46) : error C2143: syntax error : missing ';' before '}' D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(46) : error C2143: syntax error : missing ';' before '}' D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(46) : error C2143: syntax error : missing ';' before '}' D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(46) : error C2143: syntax error : missing ';' before '}' D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(46) : error C2143: syntax error : missing ';' before '}' D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(46) : error C2143: syntax error : missing ';' before '}' D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(46) : error C2143: syntax error : missing ';' before '}' D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(46) : error C2143: syntax error : missing ';' before '}' D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(46) : error C2143: syntax error : missing ';' before '}' D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(46) : error C2143: syntax error : missing ';' before '}' D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(46) : error C2143: syntax error : missing ';' before '}' D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' d:\programming\templat\queue.h(46) : fatal error C1003: error count exceeds 100; stopping compilation D:\PROGRAMMING\templat\Main.cpp(9) : while compiling class-template member function '__thiscall Queue<int>::Queue<int>(int)' Error executing cl.exe. templat.exe - 102 error(s), 0 warning(s) |
Сообщ.
#7
,
|
|
|
Перенёс всё правильно. Это ошибки в твоём коде, исправляй
Добавлено Цитата VictorSh @ d:\programming\templat\queue.h(40) : error C2758: 'maxsize' : must be initialized in constructor base/member initializer list template <class Data> Queue<Data>::Queue<Data>(int number) : begin(0) , end(0) , elemCT(0) , maxsize(number) , queue(new* Data[number]) { }; Добавлено Цитата VictorSh @ d:\programming\templat\queue.h(41) : error C2166: l-value specifies const object У тебя maxsize объявлен как const, а те ему пытаешься присвоить значение maxsize = obj.maxsize; очевидно в твоём операторе = либо этого делать не нужно, либо нужно убрать у него const и выделять новый буфер с новым maxsize И т.д. и т.п. |
Сообщ.
#8
,
|
|
|
template <class Data> Queue<Data>::Queue(int number) : maxsize(number) { queue = new Data[number]; begin = 0; end = 0; elemCT = 0; }; |