作者darkpoet (darkpoet)
站內C_and_CPP
標題[問題] VC6, binary_function, and virtual
時間Sat Jun 13 15:04:15 2009
各位板友好,下面的程式碼我在 VC6 上面執行會當掉,在 DevC++4980 不會。
在 VC6 上面只要將紫色部份任選一個刪除就可以正常執行,
請教各位大大,這是我的程式碼有錯或是 VC6 的問題呢?
謝謝大家的幫忙! Orz
#include <functional>
using std::binary_function;
#include <vector>
using std::vector;
#include <algorithm>
using std::sort;
class CSmaller
: public binary_function<int, int, bool>
{
public:
virtual bool operator()(int lhs, int rhs) const
{
return lhs < rhs;
}
};
int main()
{
vector <int> pop(17, 1);
sort(pop.begin(), pop.end(), CSmaller());
return 0;
}
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 118.160.149.152
1F:推 zlw:VC9,可編譯執行無誤 06/13 15:08
2F:推 stonehomelaa:VC6的問題 太老舊了..... 06/13 15:40
3F:推 littleshan:請養成好習慣,不要在 #include 前寫 using 06/13 15:44
4F:→ darkpoet:感謝大家的回覆!之前好像有看過文章提到 ls 大說的好習 06/13 16:20
5F:→ darkpoet:慣,不過忘記理由是什麼了,可以請 ls 大補充一下嗎?Orz 06/13 16:21
6F:推 zlw:我只想得到一點,你在#include <iostream>之前就在使用 using 06/13 16:41
7F:→ zlw:namespace std;但這時候編譯器根本不認識std。另外應該還有 06/13 16:41
8F:→ zlw:衝突的問題,以前似乎有遇過一次,但沒仔細追蹤 06/13 16:42