Sunday, February 13, 2022

[c++] Overloading class member access (C++ only)

 #include <iostream>

using namespace std;


struct Y {

  void f() {

    cout << "call f()" << endl;

  };

};


struct X {

 Y* ptr;

 Y* operator->() {

   return ptr;

 };

};


int main() {

  X x;

  x->f();

}

call f()

No comments:

Post a Comment

n8n index

 【n8n免費本地端部署】Windows版|程式安裝x指令大補帖  【一鍵安裝 n8n】圖文教學,獲得無限額度自動化工具&限時免費升級企業版功能