Thread View: borland.public.cppbuilder.nativeapi
3 messages
3 total messages
Started by Brian Dumas
Fri, 11 Apr 2003 14:31
template newbie question
Author: Brian Dumas
Date: Fri, 11 Apr 2003 14:31
Date: Fri, 11 Apr 2003 14:31
16 lines
1422 bytes
1422 bytes
I have a template defined similar to this
template <typename K, typename T>
class myclass
{
...
}
Now, when values of type K are sent in, I want to convert the value of K to
a string. But, I need to know the type. If K is a string, then I don't need
to change anything. If K is an integer, the I'll use IntToStr, if K is a
double I can use FormatFloat. But how do I determine K's type. I tried using
typeid in a series of if/else statements, but it won't compile. Any
ideas????
thanks, Brian
Re: template newbie question
Author: Pete Fraser
Date: Fri, 11 Apr 2003 14:48
Date: Fri, 11 Apr 2003 14:48
24 lines
1783 bytes
1783 bytes
You can use the automatic conversions for AnsiString.
as in:
AnsiString Str = 1;
AnsiString Str = 1.1;
HTH Pete
"Brian Dumas" <brian@kvdco.com> wrote in message news:3e96d1d8
$1@newsgroups.borland.com...
I have a template defined similar to this
template <typename K, typename T>
class myclass
{
...
}
Now, when values of type K are sent in, I want to convert the value of K to
a string. But, I need to know the type. If K is a string, then I don't need
to change anything. If K is an integer, the I'll use IntToStr, if K is a
double I can use FormatFloat. But how do I determine K's type. I tried using
typeid in a series of if/else statements, but it won't compile. Any
ideas????
thanks, Brian
Re: template newbie question
Author: Brian Dumas
Date: Fri, 11 Apr 2003 14:59
Date: Fri, 11 Apr 2003 14:59
35 lines
1918 bytes
1918 bytes
thanks, I'll try it.
"Pete Fraser" <pete.fraser@at.frasersoft.dot.net> wrote in message
news:3e96d5b5@newsgroups.borland.com...
> You can use the automatic conversions for AnsiString.
> as in:
> AnsiString Str = 1;
> AnsiString Str = 1.1;
> HTH Pete
>
> "Brian Dumas" <brian@kvdco.com> wrote in message news:3e96d1d8
> $1@newsgroups.borland.com...
> I have a template defined similar to this
>
> template <typename K, typename T>
> class myclass
> {
> ...
> }
>
> Now, when values of type K are sent in, I want to convert the value of K
to
> a string. But, I need to know the type. If K is a string, then I don't
need
> to change anything. If K is an integer, the I'll use IntToStr, if K is a
> double I can use FormatFloat. But how do I determine K's type. I tried
using
> typeid in a series of if/else statements, but it won't compile. Any
> ideas????
>
> thanks, Brian
>
>
>
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads