标题:[求助]无法运行
只看楼主
xialup
Rank: 1
等 级:新手上路
帖 子:84
专家分:0
注 册:2006-3-20
 问题点数:0 回复次数:1 
[求助]无法运行
#include <iostream>
#include <stdlib.h>
#include<ctime>
using namespace std;
class tradespace{
public:
virtual void sayhi(){cout<<"jack hi"<<endl;}
};
class tailor:public tradespace{
public:
void sayhi(){cout<<"tailor hi"<<endl;}
};
class tinker:public tradespace{
public:
void sayhi(){cout<<"tinker hi"<<endl;}
};
int main(){
srand(time(0));
tradespace* p[10];
unsigned k,j;
for(j=0;j<10;j++)
k=1+rand()%3;
switch(k)
{
case 1:p[j]=new tradespace;break;
case 2:p[j]=new tailor;break;
case 3:p[j]=new tinker;break;
}
for(j=0;j<10;j++){
p[j]->sayhi();
delete p[j];
}
system("pause");
return 0;
}
编译通过 无法运行~~
搜索更多相关主题的帖子: 运行 
2006-06-01 11:02
xialup
Rank: 1
等 级:新手上路
帖 子:84
专家分:0
注 册:2006-3-20
得分:0 

晕死 FOR循环体少了符号`~汗^^^^^


#include <iostream>
#include <stdlib.h>
#include<ctime>
using namespace std;
class tradespace{
public:
virtual void sayhi(){cout<<"jack hi"<<endl;}
};
class tailor:public tradespace{
public:
void sayhi(){cout<<"tailor hi"<<endl;}
};
class tinker:public tradespace{
public:
void sayhi(){cout<<"tinker hi"<<endl;}
};
int main(){
srand(time(0));
tradespace* p[10];
unsigned k,j;
for(j=0;j<10;j++){
k=1+rand()%3;
switch(k)
{
case 1:p[j]=new tradespace;break;
case 2:p[j]=new tailor;break;
case 3:p[j]=new tinker;break;
}
}
for(j=0;j<10;j++){
p[j]->sayhi();
delete p[j];
}
system("pause");
return 0;
}

[此贴子已经被作者于2006-6-1 11:09:29编辑过]


2006-06-01 11:08



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-68955-1-1.html




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

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