I've a problem with c++ function overloading. Here is an example class.
class test
{
public:
const char* data() const
{
std::cout << "const char* data() const" << std::endl;
return data_;
}
char* data()
{
std::cout << "char* data()" << std::endl;
return data_;
}
private:
char data_[512];
};
In my example I've two function calls.
test t;
const char *t1 = t.data();
char* t2 = t.data();
And my output is char* data() twice. Can someone explain me whats going on? Why is const char* data() const never been called?
Thanks for help.
this. But the OP was clearly trying to overload on the return value.