Skip to content

结构体

1 分析运行结果

观察以下最简单的指针代码,它的运行结果会是怎么样呢?

cpp
#include <iostream>
using namespace std;

struct Phone {
    string brand;      // 品牌
    string model;      // 型号
    string os;         // 操作系统
};

int main() {
    Phone myPhone = {"apple","iphone18","ios26"};
    cout << myPhone.brand << endl;
    return 0;
}
输出示例

输入密码才能查看参考答案噢