从Scratch 2学到的一些编程思想
所有程序都是事件驱动的
原文:http://blog.csdn.net/zoomdy/article/details/50530917 mingdu.zheng at gmail dot com
Scratch是麻省理工大学(MIT)为8~16岁的孩子开发的编程工具。Scratch的基本…
js中给出关于回调函数的解释为: A callback is a function that is passed as an argument to another function and is executed after its parent function has completed. 意思就是说,回调函数是与其他另外一个函数异步进行的,并且该函数是…
一.函数指针
#include <iostream>typedef void (*callback)(int ,int);
class MyTest
{
public:void setCallback(callback cb){m_callback = cb;}void add(int a, int b){m_callback(a, b);}private:callback m_callback;
};void onCallback(int a, int b)
{std::cout …
先来看几段程序:
1. 首先定义一个类Caller,这个类里面保存一个接口引用。 public class Caller { private MyCallInterface callInterface; public Caller() { } public void setCallFunc(MyCallInterface callInterface) {…