[問題] 用類別建立物件後無法存取其他項目
我的主程式是
#include <iostream>
#include "HeapSort.h"
using namespace std;
int main()
{
HeapSort case1();
case1.show();
system("pause");
return 0;
}
HeapSort.h的內容是
class HeapSort
{
public:
HeapSort();
~HeapSort();
int get_size();
void interchange(int *a, int *b);
bool check_node_is_exist(int *node);
void compare_value_and_interchange(int *parent, int *child_1, int
*child_2);
void change_node();
void show();
private:
int size, *data, counter, index;
};
然後編譯出來的錯誤訊息是(dev-c)
request for member `show' in `case1', which is of non-class type `HeapSort ()()'
Visual Studio 2008說是
error C2228: '.show' 的左邊必須有類別/結構/等位
問題出在哪裡@@?
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 123.195.208.178
→
03/11 20:22, , 1F
03/11 20:22, 1F
推
03/11 20:24, , 2F
03/11 20:24, 2F
→
03/11 20:24, , 3F
03/11 20:24, 3F
我一開始也沒有括弧
可是就出現
[Linker error] undefined reference to `HeapSort::HeapSort()'
[Linker error] undefined reference to `HeapSort::show()'
[Linker error] undefined reference to `HeapSort::~HeapSort()'
[Linker error] undefined reference to `HeapSort::~HeapSort()'
Visual Studio 2008則出現
1>main.obj : error LNK2019: 無法解析的外部符號 "public: __thiscall
HeapSort::~HeapSort(void)" (??1HeapSort@@QAE@XZ) 在函式 _main 中被參考
1>main.obj : error LNK2019: 無法解析的外部符號 "public: void __thiscall
HeapSort::show(void)" (?show@HeapSort@@QAEXXZ) 在函式 _main 中被參考
1>main.obj : error LNK2019: 無法解析的外部符號 "public: __thiscall
HeapSort::HeapSort(void)" (??0HeapSort@@QAE@XZ) 在函式 _main 中被參考
實做部分在這http://src.wtgstudio.com/?n708kU
※ 編輯: herman602 來自: 123.195.208.178 (03/11 20:35)
→
03/11 21:29, , 4F
03/11 21:29, 4F
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章
26
152