Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Nested Template Class failed

Reply
Thread Tools

Nested Template Class failed

 
 
Nephi Immortal
Guest
Posts: n/a
 
      01-11-2013
Why doesn’t my code work?

Error 3 error C2511: 'void Outer<Outer_Type>::_Type<Type1>::test(void)' : overloaded member function not found in 'Outer<Outer_Type>::_Type<Type1>' d:\main.cpp

enum Types
{
Type1,
Type2
};

template< Types Outer_Type >
struct Outer
{
template< Types Type >
struct _Type;

template<>
struct _Type< Type1 >
{
void test();
};

_Type< Type1 > Do();
};

void Outer< Type1 >::_Type< Type1 >::test()
{
}

Outer< Type1 >::_Type< Type1 > Outer< Type1 >:o()
{
return _Type< Type1 >();
}

int main()
{
Outer< Type1 > x;
x.Do().test();

return 0;
}
 
Reply With Quote
 
 
 
 
Zhihao Yuan
Guest
Posts: n/a
 
      01-11-2013
On Thursday, January 10, 2013 11:26:38 PM UTC-6, Nephi Immortal wrote:
> template<>
> struct _Type< Type1 >
> {
> void test();
> };


I don't quite catch what you want to do here, but an explicit
specialization in a class scope is not allowed. However, a partial
specialization is OK.

template< Types Type, typename Enable = void>
struct _Type;

template <typename Enable>
struct _Type<Type1, Enable> {
void test();
};

> void Outer< Type1 >::_Type< Type1 >::test()
> {
> }


Syntax error. Should be:

template <> template <>
void Outer< Type1 >::_Type< Type1 >::test()
{
}


--
Zhihao Yuan, ID lichray
The best way to predict the future is to invent it.
__________________________________________________ _
4BSD -- http://4bsd.biz/
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Class nested inside a template class as template function argument type claudiu C++ 3 04-01-2011 01:02 PM
Class nested inside a template class as template function argument type claudiu C Programming 2 04-01-2011 12:10 PM
problem with a function template returning a private nested class ofa class template ymost@hotmail.com C++ 2 12-28-2008 10:43 AM
Nested Class, Member Class, Inner Class, Local Class, Anonymous Class E11 Java 1 10-12-2005 03:34 PM
A parameterized class (i.e. template class / class template) is not a class? christopher diggins C++ 16 05-04-2005 12:26 AM



Advertisments