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

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

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

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

把類(lèi)和實(shí)現(xiàn)分開(kāi)寫(xiě),再寫(xiě)一個(gè)主函數(shù),編譯無(wú)錯(cuò),但運(yùn)行出現(xiàn)問(wèn)題。將頭文件后綴改后這也是從CSDN搜到的解決方法,不知道具體原因,求問(wèn)。代碼列下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貢獻(xiàn)62條經(jīng)驗(yàn) 獲得超31個(gè)贊

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

可以參考這個(gè)文章:"undefined reference to" 問(wèn)題匯總及解決方法

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

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢(xún)優(yōu)惠詳情

幫助反饋 APP下載

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

公眾號(hào)

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