2016-05-29 52 views
-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

+0

'union'是C++中的关键字,你不能用它作为函数的名称。 – nwp

+0

@nwp是的,我改变了,顺便谢谢。 –

回答

0

您的mainint v, e;开头。因此参考v请参阅int而不是您的vector

(旁白:这些宏不要做什么他们阻碍而不是帮助可读性,并有各种缺点。)