This is a C++ class which has a member function that takes 3 arguments and converts the number from first base to second base. It takes the following arguments.

– std::string thestlstring

– int base

– int base2

The number is stored in the form of std::string and returns the number as string . It supports bases 2 till base 16.

Source code is contributed by: massiveattack92(at)hotmail.com

Sample Output

Input: thestlstring = “777”, base = 8, base2 = 10
Output: 511
Explanation: 777 in octal (base =8) when converted to decimal (base =10) is 511.

Input: thestlstring = “927”, base = 10, base2 = 16
Output: 39F
Explanation: 927 in decimal (base =10) when converted to hexadecimal (base = 16) is 39F.

You can verify these values using a scientific calculator program available in windows OS.