- In here: http://gcc.gnu.org/projects/cxx0x.html They're saying that dflt tmp args in fnc are supported by their 4.4 ver. I run ver 4.4.1 and when I try to compile this:
d - guess what this d is here for? ;)
 #include<vector>
    templ开发者_如何学Goate<class Key, class CollT = std::vector>
    CollT* delete_(Key kValue)
    {
        return new CollT;
    }
    int main()
    {
        return 0;
    }
I'm getting an error. So what's going on?
std::vector is not a class it is a template. You can put in a syntax to indicate a template as a template parameter. In your case you might just want to make it std::vector<Key>
I think the code you shown was broken: here is fix and how to build, and this works on g++ 4.4.5 so double check w/ your version:
#include<vector>
template <class Key, class CollT = std::vector<Key> >
CollT* delete_(Key kValue)
{
    return new CollT;
}
int main()
{
    return 0;
}
to build:
g++ templdef.cpp -std=c++0x
EDITs based on comments:
   1) replace typename with class within template definition (both class CollT and typename CollT seems fine)
   2) replaced `vector<int>` with `vector<Key>`
   3) compiling without flag, will give you the following error: default template arguments may not be used in function templates without -std=c++0x or -std=gnu++0x
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论