• 结构体和函数


    结构体和函数
           结构体是一种数据类型,作为数据类型,它就可以定义变量,同时也可以作为函数的形式参数,或者让函数的返回值为一个结构体类型。下面通过一个代码来说明这一点:
           #include <iostream>
           using namespace std;
           struct   people
      {
                 int    weight;
                 int     tall;
                 bool  sex;
                 int  age;
            };
            const  int  class=60;
            people  &sum(people1,people2);
            void   show(people);
            int  main()
            {
                 people  a=(80,190,1,19);
                 people  b=(90,200,1,21);
                 people *number=&total(a,b);
                 cout<<"两人总计为:"<<endl;
                 show(*number);
                 delete number;
                 return 0;
             }       
            people &sum(people t1,people t2)
    {
            people *total=new people;
            total->tall=t1.tall+t2.tall;
            total->weight=t1.weight+t2.weight;
            return  *total;
    }
            void  show(people t3)
    {
            cout<<t3.tall<<endl;
    }

  • 相关阅读:
    AIX系统/var/adm/wtmp大文件处理
    script & scriptreplay
    Ubuntu/Debianpxe/isopreseed
    Ubuntu12.04安装gimp-2.8
    Ubuntu 3D特效一览
    Unix history图览
    Undelete Files on Linux Systems
    开源界有趣的循环缩写和LOGO
    Ubuntu上的dock
    linux下歌曲、视频、文件等乱码
  • 原文地址:https://www.cnblogs.com/sunfie/p/4394596.html
Copyright © 2020-2023  润新知