I've a pair pure virtual function defined inside a c++ class, which I've overloaded. Code snippet below::
virtual uint64_t Abc::GetValue()=0;
virtual uint32_t Abc::GetValue()=0;
Here, the only difference in function signature is the return type of GetVal() " uint32_t
" & " uint64_t
"..
It's throwing compilation error that this can't be overloaded.
Plz help me on this.
You can't overload based on return type, only on parameter types. This is because the overload is chosen based on how the function is called, and a function call doesn't specify the expected return type.
Options include:
In c++ onverloading is only done on the parameters of the function not on the return type . So your are redefining the same function which is an error.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.