zoukankan      html  css  js  c++  java
  • 结构体和函数

    结构体和函数
           结构体是一种数据类型,作为数据类型,它就可以定义变量,同时也可以作为函数的形式参数,或者让函数的返回值为一个结构体类型。下面通过一个代码来说明这一点:
           #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;
    }

  • 相关阅读:
    junit4
    spring
    hibernate 的注意事项
    Struts2 的 命名规范
    Struts2 的标签
    OGNL
    添加删除 板块 struts2
    Struts2 的各种xml 和struts 配置信息 都是一样的
    struts2
    struts2
  • 原文地址:https://www.cnblogs.com/sunfie/p/4394596.html
Copyright © 2011-2022 走看看