帮我看看急

ifineedhelp 2006-10-22 09:24:28
#include <iostream>
template <class A>
{
private:
<A> *p;
<A> size;
<A> _number;
//定义数据
public:
A(<A> size=20,<A> _number=10,<A> *p=0);
~A();
bool fuzhi(<A> *p);
bool insert(int i,int x);
bool shanchu1(int i);
bool find(int i);
bool shanchu(<A> *p);
//对其私有成员操作的函数接口
}
bool <A>::fuzhi(<A> *p)
{
<A> *p=new <A>[size];
for(int a=0;a<10;a++)
{
<A> *p[a]=a+1;
}
return 1;
}
bool <A>::insert(int i,int x)
{
if(i<0||i>size||i==0)
{
return 0;
}
else if(_number>size)
{
return 0;
}
else if(i>0||i<=_number)
{
int b;
i=b;
_number++;
for(int c=1;c<=_number-i;c++)
{
*p[b]=*p[b+c];
}
return 1;
}
else if(i>0||i<=size||i>_number)
{
x=*p[i];
_number++;
}
}
bool <A>::shanchu1(int i)
{
if(i<0||i>size)
{
return 0;
}
else if(_number=0)
{
return 0;
}
else if(i>0||i>_number||i<=size)
{
cout<<"点不存在"<<endl;
return 0;
}
else if(i>0||i<=_number)
{
0=*p[i];
_number--;
}
}
bool <A>::find(int i)
{
if(i<0||i>_number||_number=0)
{
return 0;
}
else if(i>0||i<=number)
{
cout<<"*p[i]="<<*p[i]<<endl;
}
}
bool <A>::shanchu(<A> *p)
{
delete [] *p;
return 1;
}
int main()
{
int i=10;
int x=30;
<int> duixiang;
if(duixiang.fuzhi)
{
cout<<"true"<<endl;
}
if(duixiang.insert)
{
cout<<"true"<<endl;
}
if(duixiang.shanchu1)
{
cout<<"true"<<endl;
}
if(duixiang.find)
{
cout<<"true"<<endl;
}
if(duixiang.shanchu)
{
cout<<"true"<<endl;
}
return 0;

}
厄 刚刚学完C++。。写了个 数据结构的类帮我看看哪里错了。。用VC6.0 给我报出40个错下面的错误信息
C:\Documents and Settings\user\桌面\6825602.cpp(18) : error C2059: syntax error : '<end Parse>'
C:\Documents and Settings\user\桌面\6825602.cpp(19) : warning C4091: '' : ignored on left of 'bool' when no variable is declared
C:\Documents and Settings\user\桌面\6825602.cpp(19) : error C2143: syntax error : missing ';' before '<'
C:\Documents and Settings\user\桌面\6825602.cpp(19) : error C2143: syntax error : missing ';' before '<'
C:\Documents and Settings\user\桌面\6825602.cpp(19) : error C2039: 'fuzhi' : is not a member of '`global namespace''
C:\Documents and Settings\user\桌面\6825602.cpp(20) : error C2143: syntax error : missing ';' before '{'
C:\Documents and Settings\user\桌面\6825602.cpp(20) : error C2447: missing function header (old-style formal list?)
C:\Documents and Settings\user\桌面\6825602.cpp(28) : warning C4091: '' : ignored on left of 'bool' when no variable is declared
C:\Documents and Settings\user\桌面\6825602.cpp(28) : error C2143: syntax error : missing ';' before '<'
C:\Documents and Settings\user\桌面\6825602.cpp(28) : error C2143: syntax error : missing ';' before '<'
C:\Documents and Settings\user\桌面\6825602.cpp(28) : error C2039: 'insert' : is not a member of '`global namespace''
C:\Documents and Settings\user\桌面\6825602.cpp(29) : error C2143: syntax error : missing ';' before '{'
C:\Documents and Settings\user\桌面\6825602.cpp(29) : error C2447: missing function header (old-style formal list?)
C:\Documents and Settings\user\桌面\6825602.cpp(55) : warning C4091: '' : ignored on left of 'bool' when no variable is declared
C:\Documents and Settings\user\桌面\6825602.cpp(55) : error C2143: syntax error : missing ';' before '<'
C:\Documents and Settings\user\桌面\6825602.cpp(55) : error C2143: syntax error : missing ';' before '<'
C:\Documents and Settings\user\桌面\6825602.cpp(55) : error C2039: 'shanchu1' : is not a member of '`global namespace''
C:\Documents and Settings\user\桌面\6825602.cpp(56) : error C2143: syntax error : missing ';' before '{'
C:\Documents and Settings\user\桌面\6825602.cpp(56) : error C2447: missing function header (old-style formal list?)
C:\Documents and Settings\user\桌面\6825602.cpp(76) : warning C4091: '' : ignored on left of 'bool' when no variable is declared
C:\Documents and Settings\user\桌面\6825602.cpp(76) : error C2143: syntax error : missing ';' before '<'
C:\Documents and Settings\user\桌面\6825602.cpp(76) : error C2143: syntax error : missing ';' before '<'
C:\Documents and Settings\user\桌面\6825602.cpp(76) : error C2039: 'find' : is not a member of '`global namespace''
C:\Documents and Settings\user\桌面\6825602.cpp(77) : error C2143: syntax error : missing ';' before '{'
C:\Documents and Settings\user\桌面\6825602.cpp(77) : error C2447: missing function header (old-style formal list?)
C:\Documents and Settings\user\桌面\6825602.cpp(87) : warning C4091: '' : ignored on left of 'bool' when no variable is declared
C:\Documents and Settings\user\桌面\6825602.cpp(87) : error C2143: syntax error : missing ';' before '<'
C:\Documents and Settings\user\桌面\6825602.cpp(87) : error C2143: syntax error : missing ';' before '<'
C:\Documents and Settings\user\桌面\6825602.cpp(87) : error C2039: 'shanchu' : is not a member of '`global namespace''
C:\Documents and Settings\user\桌面\6825602.cpp(88) : error C2143: syntax error : missing ';' before '{'
C:\Documents and Settings\user\桌面\6825602.cpp(88) : error C2447: missing function header (old-style formal list?)
C:\Documents and Settings\user\桌面\6825602.cpp(96) : error C2143: syntax error : missing ';' before '<'
C:\Documents and Settings\user\桌面\6825602.cpp(97) : error C2065: 'duixiang' : undeclared identifier
C:\Documents and Settings\user\桌面\6825602.cpp(97) : error C2228: left of '.fuzhi' must have class/struct/union type
C:\Documents and Settings\user\桌面\6825602.cpp(99) : error C2065: 'cout' : undeclared identifier
C:\Documents and Settings\user\桌面\6825602.cpp(99) : error C2297: '<<' : illegal, right operand has type 'char [5]'
C:\Documents and Settings\user\桌面\6825602.cpp(99) : error C2065: 'endl' : undeclared identifier
C:\Documents and Settings\user\桌面\6825602.cpp(101) : error C2228: left of '.insert' must have class/struct/union type
C:\Documents and Settings\user\桌面\6825602.cpp(103) : error C2297: '<<' : illegal, right operand has type 'char [5]'
C:\Documents and Settings\user\桌面\6825602.cpp(105) : error C2228: left of '.shanchu1' must have class/struct/union type
C:\Documents and Settings\user\桌面\6825602.cpp(107) : error C2297: '<<' : illegal, right operand has type 'char [5]'
C:\Documents and Settings\user\桌面\6825602.cpp(109) : error C2228: left of '.find' must have class/struct/union type
C:\Documents and Settings\user\桌面\6825602.cpp(111) : error C2297: '<<' : illegal, right operand has type 'char [5]'
C:\Documents and Settings\user\桌面\6825602.cpp(113) : error C2228: left of '.shanchu' must have class/struct/union type
C:\Documents and Settings\user\桌面\6825602.cpp(115) : error C2297: '<<' : illegal, right operand has type 'char [5]'
Error executing cl.exe.

6825602.exe - 40 error(s), 5 warning(s)
...全文
108 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
ifineedhelp 2006-10-22
  • 打赏
  • 举报
回复
各位各位。。。。我照着课本改了下 还有3个错 帮我看看是怎么回事 拜托了。。。
#include <iostream>
using namespace std;
template <class A>
class list{
private:
A *p;
A size;
A _number;
//定义数据
public:
list(A size=20,A _number=10,A *p=0);
~list();
bool fuzhi(A *p);
bool insert(int i,int x);
bool shanchu1(int i);
bool find(int i);
bool shanchu(A *p);
//对其私有成员操作的函数接口
};
template <class A>
bool list<A>::fuzhi(A *p)
{
A *p=new A[size];
for(int a=0;a<10;a++)
{
A *p[a]=a+1;
}
return true;
}
template <class A>
bool list<A>::insert(int i,int x)
{
if(i<0||i>size||i==0)
{
return false;
}
else if(_number>size)
{
return false;
}
else if(i>0||i<=_number)
{
int b;
i=b;
_number++;
for(int c=1;c<=_number-i;c++)
{
*p[b]=*p[b+c];
}
return true;
}
else if(i>0||i<=size||i>_number)
{
x=*p[i];
_number++;
return true;
}
}
template <class A>
bool list<A>::shanchu1(int i)
{
if(i<0||i>size)
{
return false;
}
else if(_number=0)
{
return false;
}
else if(i>0||i>_number||i<=size)
{
cout<<"点不存在"<<endl;
return false;
}
else if(i>0||i<=_number)
{
0=*p[i];
_number--;
return true;
}
}
template <class A>
bool list<A>::find(int i)
{
if(i<0||i>_number||_number=0)
{
return false;
}
else if(i>0||i<=number)
{
cout<<"*p[i]="<<*p[i]<<endl;
return true;
}
}
template <class A>
bool list<A>::shanchu(A *p)
{
delete [] *p;
return true;
}
int main()
{
int i=10;
int x=30;
list<int> duixiang;
if(duixiang.fuzhi(*p))
{
cout<<"tre"<<endl;
}
if(duixiang.insert(i,x))
{
cout<<"tre"<<endl;
}
if(duixiang.shanchu1(i))
{
cout<<"tue"<<endl;
}
if(duixiang.find(i))
{
cout<<"tre"<<endl;
}
if(duixiang.shanchu(*p))
{
cout<<"tre"<<endl;
}
return 0;
}
C:\Documents and Settings\user\桌面\rrw.cpp(106) : error C2065: 'p' : undeclared identifier
C:\Documents and Settings\user\桌面\rrw.cpp(106) : error C2100: illegal indirection
C:\Documents and Settings\user\桌面\rrw.cpp(122) : error C2100: illegal indirection
wangwen116 2006-10-22
  • 打赏
  • 举报
回复
语法有错误
好好检查
ehfaafzv 2006-10-22
  • 打赏
  • 举报
回复
BOOL的返回值使用true或者是false
#include《》后面加上using namespace std;
huangyangman 2006-10-22
  • 打赏
  • 举报
回复

ps: 我这只有38个错误,4个warning
建议lz来我机子上改错
呵呵.
Jokar 2006-10-22
  • 打赏
  • 举报
回复
错误不少,建议lz还是好好看看 类模板 写作的基本语法吧~

64,282

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧