CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
山寨机中的战斗机! 程序优化工程师到底对IT界有没有贡献
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  C/C++ >  C++ 语言

帮忙看一下,我调试不过去,是什么问题?谢了。

楼主sharuxing(寻圆)2005-02-03 20:24:11 在 C/C++ / C++ 语言 提问

//AppMain.cpp  
  #include   <iostream>  
  #include"Tdate.h"  
  #include"People.h"  
  #include"in_out.h"    
     
  void   main()  
  {      
  people   p1;  
  p1.output();  
  p1.input();  
  p1.output();  
  people   p2(p1);  
  cout<<"another   people..."<<endl;  
  p2.output();  
  }  
   
  //Tate.h  
  class   Tdate  
  {  
  public:  
  Tdate(int   m=1,int   d=0,int   y=1995)  
  {  
  month=m;day=d;year=y;  
  }  
  int   &getm(){return   month;}  
  int   &getd(){return   day;}  
  int   &gety(){return   year;}  
  protected:  
  int   month;int   day;int   year;  
  };    
   
  //People.h  
  class   people  
  {  
  private:  
  int   number;char   sex;int   id;   Tdate   birthday;  
  public:  
  people(int   n=0,char   s='m',int   i=32000000,int   m=1,int   d=0,int   y=1995):birthday(m,d,y)  
  {number=n;sex=s;id=i;}  
  };  
   
  people::people(people   &p)  
  {  
  number=p.number;  
  sex=p.sex;  
  id=p.id;  
  birthday.gety()=p.birthday.gety();  
  birthday.getm()=p.birthday.getm();  
  birthday.getd()=p.birthday.getd();  
  cout<<"copy..."<<endl;  
  }  
   
  //in_out.h  
  void   output()  
  {  
  cout<<"the   information   of   pleple:"<<endl;  
  cout<<"number"<<number<<endl;  
  cout<<"sex"<<sex<<endl;  
  cout<<"id"<<id<<endl;  
  cout<<"birthday"<<birthday.gety()<<"--"<<birthday.getm()<<"--"  
  <<birthday.getd()<<endl;  
  }  
  people(people   &p);  
  ~people(){cout<<"析构..."<<endl;};  
   
  void   input()  
  {  
  cout<<"\n   input   number:";  
  cin>>number;  
  cout<<"\n   input   sex:";  
  cin>>sex;  
  cout<<"\n   input   id:";  
  cin>>id;  
  cout<<"\n   input   year   of   birthday:";  
  cin>>birthday.gety();  
  cout<<"\n   input   month   of   birthday:";  
          cin>>birthday.getm();  
  cout<<"\n   input   day   of   birthday:";  
  cin>>birthday.getd();  
  }  
   
  请那位大哥指点一下是那没写对。导致编译不过去。 问题点数:50、回复次数:12Top

1 楼heskyII(赫斯基)回复于 2005-02-03 21:07:53 得分 0

在CLASS   PEOPLE中i是int类型,其长度最多在-32768到32767(UNSIGNED   INT   是0到65535)范围内  
  其他的还正在看  
  Top

2 楼heskyII(赫斯基)回复于 2005-02-03 21:15:58 得分 0

虽然你有Tdate类类型的定义,但在类PEOPLE中Tdate并不能被识别到,编译也会报错  
  除非你把所有有关连的头文件都定义在一个.H中,然后再#INCLUDE到MAIN函数里,进行编译Top

3 楼heskyII(赫斯基)回复于 2005-02-03 21:40:20 得分 25

应该是People::input(){......}  
  对类中私有对象有使用全限的只能是该类中的成员函数,有其他方式可以调用,但很繁琐.  
  Top

4 楼pdaliu(刘星)回复于 2005-02-03 22:13:55 得分 0

using   namespace   std;  
   
  写上这个呢?好像不写这个cout不能用的!Top

5 楼pdaliu(刘星)回复于 2005-02-03 22:20:20 得分 0

people(people   &p);  
  ~people(){cout<<"析构..."<<endl;};  
   
  这样写行吗?好像要加pepole::吧?是不是啊?~~我刚学类的!Top

6 楼sharuxing(寻圆)回复于 2005-02-03 22:30:59 得分 0

using   namespace   std;  
  写上也不行啊。。。。  
  --------------------Configuration:     -   Win32   Debug--------------------  
  Compiling...  
  AppMain.cpp  
  people.h(13)   :   error   C2511:   'people::people'   :   overloaded   member   function   'void   (class   people   &)'   not   found   in   'people'  
   
  我理解好像是提示,people类的拷贝构造函数people有问题。不知道出在什么地方上了。  
  Top

7 楼pdaliu(刘星)回复于 2005-02-03 22:41:32 得分 0

heskyII(赫斯基)  
   
  int它的范围和机器有关(好像是这样!要不就是和编译器有关)!我的int型占4个字节!-32768~32767是占2个字节Top

8 楼pdaliu(刘星)回复于 2005-02-03 22:45:30 得分 0

那我也说不上了~...  
   
  你最好把他们都放到一个文件里编译一下!(当然这是一个笨方法~)Top

9 楼pdaliu(刘星)回复于 2005-02-03 22:50:28 得分 0

再多问一下~这是什么用处啊?输入生日的?Top

10 楼zjyu88(刚步入三流大学)回复于 2005-02-03 23:32:13 得分 25

你在people类里都没定义它的拷贝构造函数..  
  奇怪的是people的析构函数写在in_out.h里...而且在people里也没定义析构函数.Top

11 楼sharuxing(寻圆)回复于 2005-02-03 23:35:13 得分 0

是啊。。。用来输人的生日Top

12 楼sharuxing(寻圆)回复于 2005-02-04 01:31:29 得分 0

people成员函数input(),output()写错地方了,应该定义在people类里面的publc成员里面,这样主程序才能调用的了。  
  修改如下:  
  //AppMain.cpp  
  #include   <iostream>  
  using   namespace   std;    
  #include"Tdate.h"  
  #include"People.h"  
  void   main()  
  {      
  people   p1;  
  p1.output();  
  p1.input();  
  p1.output();  
  people   p2(p1);  
  cout<<"another   people..."<<endl;  
  p2.output();  
  }  
   
  //Tdate.h  
  class   Tdate  
  {  
  public:  
  Tdate(int   m=1,int   d=0,int   y=1995)  
  {  
  month=m;day=d;year=y;  
  }  
  int   &getm(){return   month;}  
  int   &getd(){return   day;}  
  int   &gety(){return   year;}  
  protected:  
  int   month;int   day;int   year;  
  };  
   
  //People.h  
  class   people  
  {  
  private:  
  int   number;char   sex;int   id;   Tdate   birthday;  
  public:  
  people(int   n=0,char   s='m',int   i=32000000,int   m=1,int   d=0,int   y=1995):birthday(m,d,y)  
  {number=n;sex=s;id=i;}  
  void   output()  
  {  
  cout<<"the   information   of   pleple:"<<endl;  
  cout<<"number   "<<number<<endl;  
  cout<<"sex   "<<sex<<endl;  
  cout<<"id   "<<id<<endl;  
  cout<<"birthday   "<<birthday.gety()<<"--"<<birthday.getm()<<"--"  
  <<birthday.getd()<<endl;  
  }  
  people(people   &p);  
  ~people(){cout<<"析构..."<<endl;}  
   
  void   input()  
  {  
  cout<<"\n   input   number:";  
  cin>>number;  
  cout<<"\n   input   sex:";  
  cin>>sex;  
  cout<<"\n   input   id:";  
  cin>>id;  
  cout<<"\n   input   year   of   birthday:";  
  cin>>birthday.gety();  
  cout<<"\n   input   month   of   birthday:";  
          cin>>birthday.getm();  
  cout<<"\n   input   day   of   birthday:";  
  cin>>birthday.getd();  
  }  
  };  
   
  people::people(people   &p)  
  {  
  number=p.number;  
  sex=p.sex;  
  id=p.id;  
  birthday.gety()=p.birthday.gety();  
  birthday.getm()=p.birthday.getm();  
  birthday.getd()=p.birthday.getd();  
  cout<<"copy..."<<endl;  
  }  
   
  谢谢各位帮助。  
   
   
  Top

相关问题

  • 请大侠帮忙看一下是什么问题(OpenGL调试)
  • 拜托,看一下什么错误,谢谢!(Win200Server+Resin2.0.5)
  • 不懂它到底想要什么, 帮忙看一下? 谢谢。
  • 帮我看一下,这段程序什么意思,谢谢!
  • vs2005里一个原来在2003里写的html调试不过去,大家帮我看一下。谢谢
  • 请懂行的帮我看一下这是什么,多谢了。
  • 哪位达人帮我看一下有什么问题.谢了
  • 能帮忙看一下这个程序有什么问题吗? 谢谢
  • 大家快我看一下,为什么总是提示'书签无效'?谢谢!
  • 请指教我的jtable 为什么不显示???谢谢看一下。

关键词

  • birthday
  • people
  • getd
  • getm
  • cout
  • tdate
  • gety
  • sex
  • 类
  • output

得分解答快速导航

  • 帖主:sharuxing
  • heskyII
  • zjyu88

相关链接

  • C/C++ Blog
  • C/C++类图书
  • C/C++类源码下载

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
北京创新乐知广告有限公司 版权所有, 京 ICP 证 070598 号
世纪乐知(北京)网络技术有限公司 提供技术支持
Copyright © 2000-2008, CSDN.NET, All Rights Reserved
GongshangLogo