.


:




:

































 

 

 

 





 

. , .

 

, - , - . , , , . -, . ++: , , . , , :

 

/local/include/stl/_algo.h: In function 'struct _STL::_List_iterator<_STL::basic
_string<char,_STL::char_traits<char>,_STL::allocator<char> >,_STL::_Nonconst_tra
its<_STL::basic_string<char,_STL::char_traits<char>,_STL::allocator<char> > > >
_STL::find_if<_STL::_List_iterator<_STL::basic_string<char,_STL::char_traits<cha
r>,_STL::allocator<char> >,_STL::_Nonconst_traits<_STL::basic_string<char,_STL::
char_traits<char>,_STL::allocator<char> > > >, _STL::binder2nd<_STL::greater<int
> > >(_STL::_List_iterator<_STL::basic_string<char,_STL::char_traits<char>,_STL:
:allocator<char> >,_STL::_Nonconst_traits<_STL::basic_string<char,_STL::char_tra
its<char>,_STL::allocator<char> > > >, _STL::_List_iterator<_STL::basic_string<c
har,_STL::char_traits<char>,_STL::allocator<char> >,_STL::_Nonconst_traits<_STL:
:basic_string<char,_STL::char_traits<char>,_STL::allocator<char> > > >, _STL::bi
nder2nd<_STL::greater<int> >, _STL::input_iterator_tag)':
/local/include/stl/_algo.h:115: instantiated from '_STL::find_if<_STL::_List_i
terator<_STL::basic_string<char,_STL::char_traits<char>,_STL::allocator<char> >,
_STL::_Nonconst_traits<_STL::basic_string<char,_STL::char_traits<char>,_STL::all
ocator<char> > > >, _STL::binder2nd<_STL::greater<int> > >(_STL::_List_iterator<
_STL::basic_string<char,_STL::char_traits<char>,_STL::allocator<char> >,_STL::_N
onconst_traits<_STL::basic_string<char,_STL::char_traits<char>,_STL::allocator<c
har> > > >, _STL::_List_iterator<_STL::basic_string<char,_STL::char_traits<char>
,_STL::allocator<char> >,_STL::_Nonconst_traits<_STL::basic_string<char,_STL::ch
ar_traits<char>,_STL::allocator<char> > > >, _STL::binder2nd<_STL::greater<int>
>)'
testprog.cpp:18: instantiated from here
/local/include/stl/_algo.h:78: no match for call to '(_STL::binder2nd<_STL::grea
ter<int> >) (_STL::basic_string<char,_STL::char_traits<char>,_STL::allocator<cha
r> > &)'
/local/include/stl/_function.h:261: candidates are: bool _STL::binder2nd<_STL::g
reater<int> >::operator ()(const int &) const

 

. , , . . .

 

, . , (, Visual Studio 2010) . , >> , 2 :

 

std::vector< std::vector< int >> vv;

 

:

 

std::vector< std::vector< int > > vv;

// ^

 

, . , , T value_type:

 

template < typename T >

class Test

{

T::value_type x;
};

 

T , T::value_type value_type. :

 

warning C4346: 'T::value_type': dependent name is not a type

prefix with 'typename' to indicate a type

see reference to class template instantiation 'Test<T>' being compiled

error C2146: syntax error: missing ';' before identifier 'x'

error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

 

, T value_type , , typename :

 

template < typename T >

class Test

{

typename T::value_type x;
};

 

. , , , <, . template:

 

class Test

{

public:

template < typename T>

int f (T _x);

};

 

template < typename T >

void f (T _x)

{

Test t;

std::cout << t. template f< T >(_x);

// : std::cout << t.f< T >(_x);

}

 

. , , . , . , .

 





:


: 2017-01-21; !; : 301 |


:

:

- , - .
==> ...

1237 - | 1184 -


© 2015-2024 lektsii.org - -

: 0.017 .