使用map時提示error C2143: syntax error : missing ‘>’ before ‘;’

來源:互聯網
上載者:User

今天在vc6.0中使用了map,在map中嵌套了vector,錯誤判錯了error C2143: syntax error : missing '>' before ';'錯誤,但是同樣的代碼,在vs2005中卻不會報錯,浪費了我很長時間,解決方案如下,希望對其他遇到同樣的朋友有所協助

編譯環境VC6.0

程式如下:

#include<vector>
#include<map>
#include<iostream>

int main()
{
     std::map<int,std::vector<int>>;
     return 0;
}

 

提示下面錯誤:

--------------------Configuration: test - Win32 Debug--------------------
Compiling...
main.cpp
D:/Program Files/Microsoft Visual Studio/MyProjects/test/main.cpp(7) : error C2143: syntax error : missing '>' before ';'
Error executing cl.exe.

main.obj - 1 error(s), 0 warning(s)

 

 

錯誤解決:

將 std::map<int,std::vector<int>>;  修改為std::map<int,std::vector<int> >;   

注意:vector<int>後面加了一個空格

 

 

 

 

在vs2005中不會報錯,可能是由於vc6.0和vs2005的編譯器不一樣的緣故吧。

 

 

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.