I am trying to overload the << operator just for understanding purposes. I was successful but I am having issues with const data types and objects. The compiler gives me the following:
Use of overloaded operator '<<' is ambiguous (with operand types 'std::__1::ostream' (aka 'basic_ostream') and 'const char')
I am using Clion with gcc on MAC and c++ 17. Can someone help me understand what the above error means and how to fix it. Code is below. Thanks!
template <typename T>
std::ostream& operator<<(std::ostream& ost, const T data) {
printf("I am very happy");
return ost;
}
int main() {
const char s = 10;
std::cout << s << std::endl;
}