unknown types c++
I have these errors i could not fixed it:
template< class char_type, class traits_type>
class invalid_streambuf : public std::basic_streambuf< char_type, traits_type>
{
typedef std::basic_streambuf< char_type, traits_type> base_class;
using typename base_class::int_type;
...
virtual int_type overflow(int_type nChar)
{ return 0; }
...
}
‘int_type’ does not name a type
template< class char_type, class traits_type>
class basic_thread_safe_log
: protected basic_message_handler_log< char_开发者_如何学运维type, traits_type>
{
typedef basic_message_handler_log< char_type, traits_type> base_class;
using typename base_class::string_type;
void on_last_message( const string_type & str)
{
assert ( str.empty());
}
...
}
ISO C++ forbids declaration of ‘string_type’ with no type
You seem to try to use types that should be known at generation of the class but they are not parametters of your template class, so they don't exist.
Here, you could fix the problem simply by using typedef instead of using.
Is that your code or somebody else's code? The compiler is telling you that int_type and string_type are not known types -- in that code there are no declarations or definitions of those types, so what the compiler is saying makes perfect sense.
Do note that char_type and traits_type are not standard C++ types, as you may be believing they are (and thus trying to use the similarly-named int_type and string_type). They are type parameters to the template in question here. In other words the bit of code template< class char_type, class traits_type>
contains the declarations of the type names that the rest of the template code is using.
It might help, however, if you ask a (separate) question about what you're trying to achieve on a higher level.
精彩评论