社区
非技术区
帖子详情
这样的代码在win2000下调试的通,但是不能运行。
yesman
2002-02-09 05:51:07
#include <iostream>
class firstclass
{
public:
char* name;
};
int main(int argc, char *argv[])
{
firstclass first;
cin >>first.name;
return 0;
}
我运行他给我报错,
...全文
18
5
打赏
收藏
这样的代码在win2000下调试的通,但是不能运行。
#include class firstclass { public: char* name; }; int main(int argc, char *argv[]) { firstclass first; cin >>first.name; return 0; } 我运行他给我报错,
复制链接
扫一扫
分享
转发到动态
举报
AI
作业
写回复
配置赞助广告
用AI写文章
5 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
wanggou
2002-02-09
打赏
举报
回复
class firstclass
{
public:
firstclass(){name = new char[255];}
~firstclass(){delete [] name;}
char* name;
friend ostream& operator<<(ostream& os,firstclass& ft)
{
os<<ft.name;
return os;
}
friend istream& operator>>(istream& is,firstclass& ft)
{
is>>ft.name;
return is;
}
};
int main(int argc, char *argv[])
{
using namespace std;
firstclass first;
cin >> first;
cout << first <<endl;;
return 0;
}
dragondwy
2002-02-09
打赏
举报
回复
指针初始化
下面的代码试试
#include <iostream>
class firstclass
{
public:
firstclass(){name = new char[255];}
~firstclass(){delete [] name;}
char* name;
};
int main(int argc, char *argv[])
{
using namespace std;
firstclass first;
cin >> first.name;
cout << first.name;
return 0;
}
artman
2002-02-09
打赏
举报
回复
name指向的地址不可预测。
artman
2002-02-09
打赏
举报
回复
每给name分配空间。
lifanxi
2002-02-09
打赏
举报
回复
来晚一步,同意楼上各位。
你类中的指针没有指到有效的内存空间,你直接就用了,往里面写字符串,当然要出错了。因此,在构造函数中要用new给他分配空间,才能用它,当然就得用析构函数把空间delete掉了。
MiniPCIeCAN-II_um.pdf
描述了在
Win
dows系统下调用动态库的方法,包括VC和VB编程语言的示例
代码
,以及接口库函数的使用流程。 10. CAN-bus数据分析和控制节点: MiniPCIeCAN-II作为CAN-bus数据分析的强大工具,广泛应用于现场总线实验室...
用
WIN
2000
做4F
2006年11月06日 21:27 我的文章现在很多人用
WIN
2000
做4F,也有不少人的4F被黑过,其实大多数4F被黑,不是什么版本后门,而是你的电脑系统被黑客入侵了,下面我会给大家详细的讲解防范措施
Win
dows
2000
含有很多的安全...
如何在
win
dow
2000
下
调试
isapi
先把isapi放在有可执行权限的目录下,在IE中访问这个dll,如果是下载而不是看到执行的结果,那是你没有设定这个目录可执行权限,把Execute Permissions设为Scripts and Executables就可以执行ISAPI了 ,例如设wwwroot...
如何在
win
dow
2000
下
调试
isapi[masterz的专栏]
先把isapi放在有可执行权限的目录下,在IE中访问这个dll,如果是下载而不是看到执行的结果,那是你没有设定这个目录可执行权限,把Execute Permissions设为Scripts and Executables就可以执行ISAPI了 ,例如设wwwroot...
网页升级需要关服务器吗,我们单位的网站系统进行升级,这期间网站需要关闭。网站服务器在本地,用的IIS。请问有什么方法呢?...
那好,我就我所标的主题“如何架设一个可以
调试
asp程序的本地服务器”来做一个叙述,我们的目的就是,如何在自己的电脑上
调试
我们所下载下来的asp源
代码
,至于其他的,我们另做他说。 因为我平时用过最多的是两个...
非技术区
15,447
社区成员
58,120
社区内容
发帖
与我相关
我的任务
非技术区
C/C++ 非技术区
复制链接
扫一扫
分享
社区描述
C/C++ 非技术区
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章