はのは、このコードを考えてみましょう:明示的なスコープ解決なしに親クラスの親のメソッドにアクセスできないのはなぜですか?
struct message
{
uint8_t* data;
size_t length;
};
class device_base
{
// ...
public:
virtual ssize_t exec(uint8_t cmd, const uint8_t* data = nullptr, size_t length = 0);
inline ssize_t exec(uint8_t cmd, const message& msg)
{
return exec(cmd, msg.data, msg.length);
}
// ...
};
class device : public device_base
{
// The exec method do not overloaded or overridden here.
};
class device_uart : public device
{
// ...
public:
ssize_t exec(uint8_t cmd, const uint8_t* data = nullptr, size_t length = 0);
void some_method(const message&);
// ...
};
// ...
void device_uart::some_method(const message& msg)
{
// exec(SOME_COMMAND, msg); // The inline method device_base::exec is invisible here by some reason.
device::exec(SOME_COMMAND, msg); // OK.
device_base::exec(SOME_COMMAND, msg); // OK too.
exec(SOME_COMMAND, msg.data, msg.length); // OK, of course.
}
インライン非仮想メソッドexec
がdevice_uart
クラスでは見られないのはなぜ?
私はそれの上に注いだので、それはしばらくの間をされているが、私はかなり確信している[**この質問**](https://stackoverflow.com/questions/1628768/why-does-an-overridden-クラスの派生クラス - 非 - 他のオーバーロード - )は、あなたが求めているように見えるものを正確にカバーしています。 – WhozCraig