zoukankan      html  css  js  c++  java
  • C++ Struct

    //指出下面程序的问题
    /*typedef struct TagStu
    {
      int n;
    }Stu;
    void test(Stu* s[])
    {
      cout<<s->n<<endl;
      cout<<(++s)->narrow<<endl;
    }
    int main()
    {
      Stu* sTmp;
      sTmp = new Stu[10];
      test(sTmp); //传递的实参为指针,而test函数形参为Stu指针类型的数组,
      delete [] sTmp;
      return 0;
    }*/

    //修改为
    typedef struct TagStu
    {
      int n;
    }Stu;
    void test(Stu* s,int len)
    {
      cout<<s->n<<endl;
      cout<<(++s)->n<<endl;
    }
    int main()
    {
      Stu* sTmp;
      sTmp = new Stu[10];
      test(sTmp,10);
      delete [] sTmp;
      return 0;
    }

  • 相关阅读:
    STL容器[26]
    SHELL[01]
    SHELL[04]
    SHELL[02]I/O重定向
    STL容器[39]
    stl.set用法总结
    STL容器[33]
    STL容器[29]
    hdu acm1071
    hdu acm 2673
  • 原文地址:https://www.cnblogs.com/fenghuan/p/4885270.html
Copyright © 2011-2022 走看看