Intrusive interface : You need to explicitly create a class to implement an interface .

Non intrusive interface : There is no need to explicitly create a class to implement an interface .

C++ Intrusive interface :

#include <iostream> enum SEX { MAIL, FEMAIL }; class PeopleInterface { public:
PeopleInterface(){}; virtual ~PeopleInterface(){}; virtual int getSex() = 0; };
class Man : public PeopleInterface { public: Man(){}; ~Man(){}; int getSex()
{return MAIL;} }; int main(int argc, char const *argv[]) { Man m;
std::cout<<"sex:"<<m.getSex()<<std::endl; return 0; }
go Non intrusive interface

package main import "fmt" type People interface { getSex() } type Man struct {
} func (m Man) getSex() int { return 0 } func main() { var m Man fmt.Println(
"sex:", m.getSex()) }

Want to implement an interface , Directly implement the methods contained in the interface , Don't worry too much about which method belongs to which interface .

Technology
©2019-2020 Toolsou All rights reserved,
Final review of database : Summary of comprehensive application questions use Python Make simple games Laplance operator ( Second derivative ) Convert hard disk to GPT Partition format Python Implementation of Hanoi Tower code about String How to create objects vue3 Learning journey 1—— establish vue3 project java String from back to front _Java String String summary use Python Write a story about plants versus zombies 【 Greedy Algorithm 】 Huffman coding problem