c++中的struct关键字详解

struct关键字是用来定义一个新的类型,这个新类型里面可以包含各种其他类型,称为结构体。

 

#include <stdio.h>

typedef struct {
        int a;
        int b;
}Stu;

Stu getStu(int x, int y)
{
        Stu result;
        result.a = x;
        result.b = y;
        return result;
}

int main()
{
        int a = 2, b = 3;
        Stu test = getStu(a, b);
        printf("%d %d\n", test.a, test.b);
        return 0;
}

 

 

 

posted on 2020-08-17 11:24  玩转机器学习  阅读(532)  评论(0编辑  收藏  举报