zl程序教程

您现在的位置是:首页 >  后端

当前栏目

【C语言】C语言面向对象的接口封装实现

C语言封装接口 实现 面向对象
2023-09-14 09:05:33 时间

目录

Operator.h

Operator.c

main.c


Operator.h

//
// Created by cjs0719 on 2022/6/24.
//

#ifndef UNTITLED1_OPERATOR_H
#define UNTITLED1_OPERATOR_H

typedef struct {
    int age;
    int num;
}Stu;

typedef struct {
    void *handle;
    Stu stu;
    int (*Add)(struct S_FAN_STU_OP *stu_op,int a,int b);
}S_FAN_STU_OP;

extern S_FAN_STU_OP* Initialize(void);

#endif //UNTITLED1_OPERATOR_H

Operator.c

//
// Created by cjs0719 on 2022/6/24.
//
#include "Operator.h"
#include <stdlib.h>

static int add_num(S_FAN_STU_OP *stu_op,int a,int b);


static int add_num(