更新时间:2022-06-27 01:05:59
基本上,不是协议"而是具有纯虚函数的基类",有时在其他语言中也称为接口.
Basically, instead of "Protocol" think "base class with pure virtual functions", sometimes called an interface in other languages.
class Protocol
{
public:
virtual void Foo() = 0;
};
class Class : public Protocol
{
public:
void Foo() { }
};
class Class2 : public Protocol
{
public:
void Foo() { }
};
class TableView
{
public:
void setDelegate(Protocol* proto) { }
};