void f1() { printf("f1()\n"); }
void f2() { printf("f2()\n"); }
void f3() { printf("f3()\n"); }
void do_func(void(*f)()) { f(); }
int main()
{
do_func(f1);
do_func(f2);
do_func(f3);
}
template <typename Func>
void do_func(Func f) { f(); }
int main()
{
do_func([]() { printf("f1()"); });
do_func([]() { printf("f2()"); });
do_func([]() { printf("f3()"); });
}
interface Funcable {
void Func();
}
class F1 implements Funcable {
@Override
public void Func() {
System.out.println("f1()");
}
}
public class Test {
public static void do_func(Funcable funcable) {
funcable.Func();
}
public static void main(String[] args) {
do_func(new F1());
}
}
do_func(new Funcable() {
@Override
public void Func() {
System.out.println("f2()");
}
});
String msg = "f3()";
do_func(new Funcable() {
String _msg;
{
_msg = msg;
}
@Override
public void Func() {
System.out.println(_msg);
}
});
std::string msg = "f3()";
do_func([&msg]() { std::cout << msg << std::endl; });
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有