support bazel complie this project and format code.

This commit is contained in:
zhangxing
2023-03-30 00:15:11 +08:00
committed by light-city
parent 1f86192576
commit 7529ae3a55
636 changed files with 10025 additions and 9387 deletions

View File

@@ -0,0 +1,8 @@
# please run `bazel run basic_content/func_pointer:func_pointer`
load("@rules_cc//cc:defs.bzl", "cc_binary")
cc_binary(
name = "func_pointer",
srcs = ["func_pointer.cpp"],
copts = ["-std=c++11"]
)

Binary file not shown.

View File

@@ -6,28 +6,26 @@
* @date 2019-07-20
*/
#include<iostream>
#include <iostream>
using namespace std;
/**
* @brief 定义了一个变量pFun这个变量是个指针指向返回值为空和参数为int的函数的指针
* @brief
* 定义了一个变量pFun这个变量是个指针指向返回值为空和参数为int的函数的指针
*/
void (*pFun)(int);
void (*pFun)(int);
/**
* @brief 代表一种新类型不是变量所以与上述的pFun不一样
*/
typedef void (*func)(void);
typedef void (*func)(void);
void myfunc(void)
{
cout<<"asda"<<endl;
}
void myfunc(void) { cout << "asda" << endl; }
void glFun(int a){ cout<<a<<endl;}
int main(){
func pfun = myfunc;/*赋值*/
pfun();/*调用*/
pFun = glFun;
(*pFun)(2);
void glFun(int a) { cout << a << endl; }
int main() {
func pfun = myfunc; /*赋值*/
pfun(); /*调用*/
pFun = glFun;
(*pFun)(2);
}