亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費(fèi)注冊 查看新帖 |

Chinaunix

  平臺 論壇 博客 文庫
最近訪問板塊 發(fā)新帖
查看: 3423 | 回復(fù): 2
打印 上一主題 下一主題

[C++] vs 2008 需要打補(bǔ)? 這個怎么編譯不過呢 [復(fù)制鏈接]

論壇徽章:
0
跳轉(zhuǎn)到指定樓層
1 [收藏(0)] [報告]
發(fā)表于 2010-02-20 23:23 |只看該作者 |倒序瀏覽
如下的代碼:

  1. // The ID class is used for team scoring. It holds each player's name
  2. // and score.
  3. class ID
  4. {
  5. public:
  6.     string Name;
  7.     int Score;

  8.     ID() : Name(""), Score(0) {}
  9.     ID(string NewName, int NewScore) : Name(NewName), Score(NewScore) {}
  10. };

  11. // In this example, an ID is equivalent only if both name and score match.
  12. bool operator==(const ID& x, const ID& y)
  13. {
  14.     return (x.Name == y.Name) && (x.Score == y.Score);
  15. }

  16. // IDs will be sorted by Score, not by Name.
  17. bool operator<(const ID& x, const ID& y)
  18. {
  19.     return x.Score < y.Score;
  20. }

  21. // Define a template class for a vector of IDs.
  22. typedef vector<ID> NAMEVECTOR;
復(fù)制代碼
  1. NAMEVECTOR Vector1;
  2. Vector1.push_back(ID("Karen Palmer", 2));
  3.     Vector1.push_back(ID("Ada Campbell", 1));

  4. // Sort the vector of players by score.
  5.         // !!!!!  something going wrong here.
  6.     sort(Vector1.begin(), &Vector1[Vector1.size()]);
復(fù)制代碼
編譯的時候提示:
1>        error C2780: “void std::sort(_RanIt,_RanIt,_Pr)”: 應(yīng)輸入 3 個參數(shù),卻提供了 2 個
1>        e:\program files\microsoft visual studio 9.0\vc\include\algorithm(3273) : 參見“std::sort”的聲明

1>        error C2782: “void std::sort(_RanIt,_RanIt)”: 模板 參數(shù)“_RanIt”不明確
1>        e:\program files\microsoft visual studio 9.0\vc\include\algorithm(3110) : 參見“std::sort”的聲明
1>        可能是“ID”
1>        或       “std::_Vector_iterator<_Ty,_Alloc>”
1>        with
1>        [
1>            _Ty=ID,
1>            _Alloc=std::allocator<ID>
1>        ]

不知道啥意思呢.... 貌似是說不能匹配的,但這些代碼在vc6是沒有任何問題的.

大家?guī)兔纯窗?!

論壇徽章:
2
青銅圣斗士
日期:2015-11-26 06:15:59數(shù)據(jù)庫技術(shù)版塊每日發(fā)帖之星
日期:2016-07-24 06:20:00
2 [報告]
發(fā)表于 2010-02-21 01:51 |只看該作者
C++要求sort前2個參數(shù)即迭代器類型相同。
C++并不要求sort處理類型不同的情況。

VC6的stl實現(xiàn)對此開了一個小門, 不代表所有C++和stl實現(xiàn)都會如此。

  1. sort(Vector1.begin(), &Vector1[Vector1.size()]);

  2. // 改為
  3. sort(v.begin(), v.end() );
  4. // 或者
  5. sort(&v[0], &v[v.size()] );
復(fù)制代碼

論壇徽章:
0
3 [報告]
發(fā)表于 2010-02-21 09:33 |只看該作者
感謝! 搞定了!

怪不得好多人在說VC6支持標(biāo)準(zhǔn)C++不咋地呢。這么多毛病.
您需要登錄后才可以回帖 登錄 | 注冊

本版積分規(guī)則 發(fā)表回復(fù)

  

北京盛拓優(yōu)訊信息技術(shù)有限公司. 版權(quán)所有 京ICP備16024965號-6 北京市公安局海淀分局網(wǎng)監(jiān)中心備案編號:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報專區(qū)
中國互聯(lián)網(wǎng)協(xié)會會員  聯(lián)系我們:huangweiwei@itpub.net
感謝所有關(guān)心和支持過ChinaUnix的朋友們 轉(zhuǎn)載本站內(nèi)容請注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP