c++学习6 -- 结构体

#include <iostream>
using namespace std;

struct Node
{
    int m;
    void fun()
    {
        printf ("hello c++");
    }
};

int main()
{
    Node a;
    a.fun();
    system("pause");
    return 0;
}

//c++ 独有 生命变量可以不用struct关键字 、 可以放函数成员,c语言不可以放函数成员,但是可以放函数地址 、 是一个特殊的类
//c的用法

#include <stdio.h>


struct Node
{
    int m;
    void (*p)();
};
void fun()
{
    printf ("hello c");
}

int main(void)
{
    struct Node a = {1,fun};
    a.p();
    return 0;
}
原文地址:https://www.cnblogs.com/mohu/p/8953979.html