Final answer:
To write a function in C++ that returns the hexadecimal representation of an integer, you can use the 'std::hex' stream manipulator.
Step-by-step explanation:
To write a function in C++ that returns the hexadecimal representation of an integer, you can use the 'std::hex' stream manipulator:
std::string decimalToHexadecimal(int num) {
std::stringstream ss;
ss << std::hex << num;
return ss.str();
}
In this function, the 'std::hex' manipulator converts the integer 'num' to hexadecimal format. The 'std::stringstream' class is used to convert the integer to a string, and the 'ss.str()' function returns the hexadecimal representation.