sync-test.cc
来自「这个程序是关于OpenC++的反射植入机制的编译器」· CC 代码 · 共 77 行
CC
77 行
/* Copyright (C) 1997,1998 Shigeru Chiba, University of Tsukuba. Permission to use, copy, distribute and modify this software and its documentation for any purpose is hereby granted without fee, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation. Shigeru Chiba makes no representations about the suitability of this software for any purpose. It is provided "as is" without express or implied warranty. July 1997: rewritten by Toru Takimoto for version 2.5.*///@beginlicenses@//@license{xerox}{}@//@endlicenses@// To see the translated program, see sync-test.ii.#include <iostream>using namespace std;// SyncClass should produce wrapper functions that calls this function.void synchronize(){ cout << "sync!\n";}metaclass SyncClass Point;class Point {public: Point(); void Move(int x, int); int X() { return x; } int Y() { return y; }private: int x, y;};Point::Point(){ x = y = 0;}// SyncClass should substitute this member function:// void Move(int nx, int ny)// {// synchronize();// ** call the original Move() **// }// for the original Move():void Point::Move(int nx, int ny){ x = nx; y = ny;}int main(){ Point p; p.Move(3, 5); int x = p.X(); int y = p.Y(); return 0;}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?