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
", test.a, test.b);
        return 0;
}

 

原文地址:https://www.cnblogs.com/shierlou-123/p/13516570.html