| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 561 人关注过本帖
标题:[求助]连接后文件很大
只看楼主 加入收藏
dubaoshi
Rank: 1
等 级:新手上路
帖 子:118
专家分:0
注 册:2006-9-22
收藏
 问题点数:0 回复次数:5 
[求助]连接后文件很大

我按教程的输入了下面的程序:
(是个练习类组合的一个东东,在编译的时候,出现了问题,加上using namespace std;这句的话,说error C2871: 'std' : does not exist or is not a namespace,不加这句的话,说error C2676: binary '<<' : 'class istream_withassign' does not define this operator or a conversion to a type acceptable to the predefined operator,我英文也不好,看不懂是啥意思,是不是程序在玩我啊?我想是我在什么地方弄错了的,哈哈,不过我真的找不到了,请高手帮我测试一下,然后把改后的程序再复制上来哟,谢过!(这个问题已经解决)

另一个问题是:程序连接完后,.exe文件居然536KB,为什么会这么大呢?我感觉很奇怪的。。。
我认为要是在50K以内的话,才能算正常的吧,请高手指教。


#include<iostream.h>

class Tdate
{
public:
Tdate(int m=1,int d=1,int y=1995)
{
month=m;
day=d;
year=y;
}
int &getm(){return month;}
int &getd(){return day;}
int &gety(){return year;}
private:
int month;
int day;
int year;
};

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=1,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.getm()=p.birthday.getm();
birthday.getd()=p.birthday.getd();
birthday.gety()=p.birthday.gety();
cout<<"copy..."<<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();
}

void output()
{
cout<<"The information people:"<<endl;
cout<<"number "<<number<<endl;
cout<<"sex "<<sex<<endl;
cout<<"id "<<id<<endl;
cout<<"birthday "<<birthday.getm()<<"--"<<birthday.getd()<<"--"<<birthday.gety()<<endl;
}

~People(){cout<<"析构。。。"<<endl;}
};

void main()
{
People p1;
p1.output();
p1.input();
p1.output();
People p2(p1);
p2.output();
}

[此贴子已经被作者于2006-11-5 7:57:11编辑过]

搜索更多相关主题的帖子: 文件 
2006-11-04 22:00
lengfei6297
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2006-10-30
收藏
得分:0 

#include<iostream.h>把里面得.h去掉

#include<iostream>就应该可以了.

2006-11-04 22:22
song4
Rank: 7Rank: 7Rank: 7
等 级:贵宾
威 望:38
帖 子:1533
专家分:4
注 册:2006-3-25
收藏
得分:0 
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();

嵌入式 ARM 单片机 驱动 RT操作系统 J2ME LINUX  Symbian C C++ 数据结构 JAVA Oracle 设计模式 软件工程 JSP
2006-11-04 22:31
leowsw
Rank: 1
等 级:新手上路
帖 子:17
专家分:0
注 册:2006-11-4
收藏
得分:0 
cin要&gt;&gt;
2006-11-05 02:33
dubaoshi
Rank: 1
等 级:新手上路
帖 子:118
专家分:0
注 册:2006-9-22
收藏
得分:0 
谢谢楼上的3位同志,已经成功!
是既要改成iostream又要改成>>,可是改成iostream和iostream.h有什么区别呢?为什么会编译不成功?

另一个问题是:就这么一个小小的程序,link以后居然536KB,是不是真的啊。。。我晕死,为什么会这么大呢?

人行善,福虽未至,祸已远离;人行恶,祸虽未至,福已远离.
2006-11-05 07:54
litcatyx
Rank: 1
等 级:新手上路
威 望:1
帖 子:151
专家分:0
注 册:2006-10-27
收藏
得分:0 
因为有些代码虽然不是你写的,但是也需要link,比如<<,>>的实现,另外,可能还有一些调试信息

2006-11-05 11:37
快速回复:[求助]连接后文件很大
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.016323 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved