第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

LNK2019,為什么直接將.h改成.cpp后就能生成解決方案成功

LNK2019,為什么直接將.h改成.cpp后就能生成解決方案成功

把類和實現(xiàn)分開寫,再寫一個主函數(shù),編譯無錯,但運行出現(xiàn)問題。將頭文件后綴改后這也是從CSDN搜到的解決方法,不知道具體原因,求問。代碼列下queue.htemplate<class?T> class?Queue { public: ?virtual?bool?IsEmpty()?const?=?0; ?virtual?bool?IsFull()??const?=?0; ?virtual?bool?Front(T&?x)?const?=?0; ?virtual?bool?EnQueue(T?x)?=?0; ?virtual?bool?DeQueue()?=?0; ?virtual?void?Clear()?=?0; };SetQueue.h#include"queue.h" template<class?T> class?SeqQueue?: ?public?Queue<T> { public: ?SeqQueue(int?mSize); ?~SeqQueue()?{?delete[]?q;?} ?bool?IsEmpty()?const?{?return?front?==?rear;?} ?bool?IsFull()?const?{?return?(rear?+?1)?%?maxSize?==?front;?} ?bool?Front(T&?x)?const; ?bool?EnQueue(T?x); ?bool?DeQueue(); ?void?Clear()?{?front?=?rear?=?0;?} private: ?int?front,?rear; ?int?maxSize; ?T?*q; };SetQueue.cpp#include"SetQueue.h" template<class?T> SeqQueue<T>::SeqQueue(int?mSize) { ?maxSize?=?mSize; ?q?=?new?T[maxSize]; ?front?=?rear?=?0; } template<class?T> bool?SeqQueue<T>::Front(T?&?x)?const { ?if?(IsEmpty()) ?{ ??cout?<<?"empty"?<<?endl; ??return?false; ?} ?x?=?q[(front?+?1)?%?maxSize]; ?return?true; } template<class?T> bool?SeqQueue<T>::EnQueue(T?x) { ?if?(IsFull()) ?{ ??cout?<<?"Full"?<<?endl; ??return?false; ?} ?q[(rear?=?(rear?+?1)?%?maxSize)]?=?x; ?return?true; } template<class?T> bool?SeqQueue<T>::DeQueue() { ?if?(IsEmpty()) ?{ ??cout?<<?"Underflow"?<<?endl; ??return?false; ?} ?front?=?(front?+?1)?%?maxSize; ?return?true; }
查看完整描述

1 回答

已采納
?
AAnonymous

TA貢獻62條經(jīng)驗 獲得超31個贊

因為.h中只是做了聲明,可能編譯時VS也沒有把中間lib編譯進來,導(dǎo)致你實例化時需要調(diào)用構(gòu)造函數(shù),它找不到構(gòu)造函數(shù)的實現(xiàn)。#include cpp時就把實現(xiàn)包含進來了

可以參考這個文章:"undefined reference to" 問題匯總及解決方法

查看完整回答
反對 回復(fù) 2018-06-01
  • 1 回答
  • 0 關(guān)注
  • 1286 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號