TArray& ListFiles( /* blah */ );
or this:
int ListFiles( TArray* /* blah */ );
and none of them return the Array Object properly. I.e. its all fuX0rd...
I''m using MSVC 6.0 BTW and so I am wondering if this is a compiler bug, template bug, or that I have to do something special (like make a good Copy constructor?).
-Cheers.
P.S. I''ve already got ideas to make a wrapper class for TArrayReturning Templates
Heya,
I''m having a serious problem here, I try to return a template class from a function and it all goes to hell. Basically I am trying to do this:
and my string class works okay.
Daemin(Dominik Grabiec)
August 07, 2001 12:31 AM
The problem is with your code; it''s not a compiler bug.
Try something like this:
Hope this helps.
Try something like this:
template TArray& ListFiles(/* blah */) {...}// Or...template int ListFiles(TArray *t, /* blah */);// Note: you may have to call your function like this:// TArray t = ListFiles(/* blah */);
Hope this helps.
August 07, 2001 12:35 AM
Sorry.... Let''s try this again, shall we?
template < typename T >
TArray< T >& ListFiles(/* blah */) {...}
// Or...
template < typename T >
int ListFiles(TArray< T > *t, /* blah */);
// Note: you may have to call your function like this:
// TArray< int > t = ListFiles< int >(/* blah */);
template < typename T >
TArray< T >& ListFiles(/* blah */) {...}
// Or...
template < typename T >
int ListFiles(TArray< T > *t, /* blah */);
// Note: you may have to call your function like this:
// TArray< int > t = ListFiles< int >(/* blah */);
Well the thing is that TArray, and BString are already defined classes, and that particular function is defined within another class.
i.e.
Strickly speaking
is just the return type.
And the way that I''m calling it is like so:
It still stuffs up then, so I am really wondering if its got anything to do with the = operator. Its just wierd...
i.e.
template class TArray { ... };// andclass BString { ... };// etc
Strickly speaking
TArray&
is just the return type.
And the way that I''m calling it is like so:
TArray Stuff = Something.ListFiles(/* blah */);
It still stuffs up then, so I am really wondering if its got anything to do with the = operator. Its just wierd...
Daemin(Dominik Grabiec)
August 08, 2001 03:03 AM
It appears your templates got cut off (because this board seems to interpret angular brackets as HTML tags).
Anyway, you can''t do something like this:
TArray t = ...;
You have to give TArray a type. So it''d be like this:
You have to specify a type for the template class when you call it.
Also, if the return type is "TArray&" (and not "TArray< T >&"), and TArray is a template then that code is probably wrong. It needs to look like:
template< typename T >
TArray< T >& Something::ListFiles(/* blah */) { ... }
Anyway, you can''t do something like this:
TArray t = ...;
You have to give TArray a type. So it''d be like this:
|
You have to specify a type for the template class when you call it.
Also, if the return type is "TArray&" (and not "TArray< T >&"), and TArray is a template then that code is probably wrong. It needs to look like:
template< typename T >
TArray< T >& Something::ListFiles(/* blah */) { ... }
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement