知识库

C++语言开发示例:08. 混合类型

2025-02-01 20:26:04 李腾 1 次阅读

mixtypes.cpp

#include <iostream>

struct antarctica_years_end
{
    int year;
};

int main()
{
    antarctica_years_end s01, s02, s03;
    s01.year = 1998;
    antarctica_years_end *pa = &s02;
    pa->year = 1999;
    antarctica_years_end trio[3];
    trio[0].year = 2003;
    std::cout << trio->year << std::endl;
    const antarctica_years_end *arp[3] = {&s01, &s02, &s03};
    std::cout << arp[1]->year << std::endl;
    const antarctica_years_end **ppa = arp;
    auto ppb = arp;
    std::cout << (*ppa)->year << std::endl;
    std::cout << (*(ppb + 1))->year << std::endl;
}
转载请注明转自www.hylab.cn,原文地址:C++语言开发示例:08. 混合类型

评论 (0)

登录后发表评论

暂无评论,快来发表第一条评论吧!