|
-
May 5th, 2005, 02:58 PM
#1
Thread Starter
PowerPoster
Class or Template? Convert integers into decimal, octal, and hexadecimal.
Ok I started writting this as a class, then realized a template may be better.
What I need to do is take 3 numbers (10, 010, 0x10 for example) decimal, octal, and hexadecimal and then output the number in all 3 formats. If 0x10 was input then I would need to output that number in decimal, octal, and hexadecimal format.
Now I figure a template would be the best way to go since 3 different kinds of numbers will be getting input into the same function. But I am not sure how to handle the conversion of these numbers. I think there is something in the stream manipulation that can handle this, but I would appreciate some help figuring it out.
Also, I am not sure, but I think I would need to return an array from the function that held all three conversions of the number. I guess it would have to be a string array unless 0x10 (for example) can be held in a int array. This is also something I do not know how to do..I can do it in VB but not C++.
Any help is appreciated!
PHP Code:
template<class T>
string convertInt( const T )
{
//convert numbers to dec, hex and oct values and return all 3
}//end convertInt
-We have enough youth. How about a fountain of "Smart"?
-If you can read this, thank a teacher....and since it's in English, thank a soldier.

Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|