Two questions...
Displaying 21-23 of 23 total.
prev 1 2
Please enter a numerical value for the importance of this sticky.
Enter 0 to unsticky.
andy

I often do this:

template >typename T<
void Swap(T& a,T& b)
{
   T c;
   c=a;
   a=b;
   b=c;
}

What that means is that the function will work with any two parameters of the same type. The compiler will simply compile one for each type used. It's also quite useful for factory classes, as you can write a single class, and use it for any number of different types.

Templates mean less code doing more work, which is Really Fricking Cool. ^_~
As for Java being portable, yes. It's possible to write unportable Java, though, (through native hooks and such) and it's possible to write portable C++.



"Ignorance is its own reward" -- Proverb

Posted on 2001-08-23 18:45:32

andy

Accidentally swapping < and > is a bad idea.

template <typename T>
void Swap(...)
{
...
}



"Ignorance is its own reward" -- Proverb

Posted on 2001-08-23 18:48:12

SmokeDog

I really need to learn more. Problem is, I only really use Java, Kornshell and all kinds of html/javascript, so that doesn't leave me any time to play with c++, which I would like to do.

Java does rock though, no-one can deny that.



Posted on 2001-08-23 23:38:55


Displaying 21-23 of 23 total.
prev 1 2
 
Newest messages

Ben McGraw's lovingly crafted this website from scratch for years.
It's a lot prettier this go around because of Jon Wofford.
Verge-rpg.com is a member of the lunarnet irc network, and would like to take this opportunity to remind you that regardless how babies taste, it is wrong to eat them.