-1
我有代碼Kruskal算法(MST),並使用雙矢量這樣使用矢量與對
vector<pair<int,pair<int,int> > > v;
我想補充懷特,使源,目標對像這樣
v.push_back(make_pair(wight,make_pair(src,des)));
和那麼
sort(v.begin(),v.end());
由於它先根據x座標排序,然後y座標
,並與錯誤
error: request for member ‘push_back’ in ‘v’, which is of non-class type ‘int’
v.push_back(MK(wt,MK(x,y)));
^
error: request for member ‘begin’ in ‘v’, which is of non-class type ‘int’
sort(v.begin(),v.end());
^
error: request for member ‘end’ in ‘v’, which is of non-class type ‘int’
sort(v.begin(),v.end());
^
我正在學習如何使用C++ STL和累調試它出現。那麼我怎樣才能推對和排序這個向量?
我的代碼鏈接。 https://ideone.com/obEhP0
'union'是C++中的關鍵字,你不能用它作爲函數的名稱。 – nwp
@nwp是的,我改變了,順便謝謝。 –