标题:[求助]扎那么多错啊, CObject
取消只看楼主
gaolu
Rank: 1
等 级:新手上路
帖 子:21
专家分:0
注 册:2006-12-7
 问题点数:0 回复次数:2 
[求助]扎那么多错啊, CObject

#include <iostream>
class CObject
{
public:
virtual int CompareTo(CObject& object)=0;
bool operator>(CObject& object);

};
bool CObject::operator >(CObject& object)
{
return CompareTo(object)>0;
}

class CNode
{
friend class LinkedList;
private:
CNode * m_prev;
CNode * m_next;
CObject * m_object;
char Name[10];
char No[10];
public:
CNode(CObject * object=NULL)
{
m_object = object;
m_prev = NULL;
m_next = NULL;
}
};

class LinkedList
{
private:
CNode * m_head;
CNode * m_rear;
int m_size;
public:
LinkedList()
{
m_size = 0;
m_head = new CNode();
m_rear = new CNode();
m_head->m_prev = NULL;
m_head->m_next = m_rear;
m_rear->m_prev = m_head;
m_rear->m_next = NULL;
char Name[10];
char No[10];
}
void Add_head(char name[],char no[])
{
Node(name,no);
rear->next=from->next;
front=&node;
size++;
}
void Add_rear(char name[],char no[])
{
Node(name,no);
rear->next=&node;
rear=&node;
size++;
}
void delete_head()
{
if(size==0)
{ cout<<"链表空"<<endl;
exit(1);
}
head=head->next;
size--;
}
void find(int index)
{ Node *m_head;
m_head=head;
if((index<0)||(index>size))
{ cout<<"结果不存在!"<<endl;
exit(1);
}
for(int i=1;i<index-1;i++)
m_head=m_head->next;
cout<<"你要查找的姓名是:"<<m_head->Name<<endl<<"学号是:"<<m_head->No<<endl;
}
void bublle(int a[],int n) //冒泡排序
{ int i,j,t,temp;
for(i=1;i<=n-1;i++)
{ t=n-1;
for(j=0;j<t-1;j++)
{ if (a[j]>a[j+1])
{ temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
}
}

};


void main()
{}

搜索更多相关主题的帖子: CObject 
2006-12-17 17:54
gaolu
Rank: 1
等 级:新手上路
帖 子:21
专家分:0
注 册:2006-12-7
得分:0 
我加了个using namespace std;但是还是有10多个错啊?帮我看看啊

冬天的梦想是我在春天的愿望^^
2006-12-17 18:17
gaolu
Rank: 1
等 级:新手上路
帖 子:21
专家分:0
注 册:2006-12-7
得分:0 

#include <iostream>
using namespace std;
class CObject
{
public:
virtual int CompareTo(CObject& object)=0;
bool operator>(CObject& object);

};
bool CObject::operator >(CObject& object)
{
return CompareTo(object)>0;
}

class CNode
{
friend class LinkedList;
private:
CNode * m_prev;
CNode * m_next;
CObject * m_object;
char Name[10];
char No[10];
public:
CNode(CObject * object=NULL)
{
m_object = object;
m_prev = NULL;
m_next = NULL;
}
};

class LinkedList
{
private:
Node * m_head;
Node * m_rear;
int m_size;
public:
LinkedList()
{
m_size = 0;
m_head = new CNode();
m_rear = new CNode();
m_head->m_prev = NULL;
m_head->m_next = m_rear;
m_rear->m_prev = m_head;
m_rear->m_next = NULL;
}
void Add_head(char name[],char no[])
{
Node(name,no);
head->next=&node;
head=node;
size++;
}
void Add_rear(char name[],char no[])
{
Node(name,no);
rear->next=&node;
rear=node;
size++;
}
void delete_head()
{
if(size==0)
{ cout<<"链表空"<<endl;
exit(1);
}
head=head->next;
size--;
}
void find(int index)
{ Node *m_head;
if((index<0)||(index>size))
{ cout<<"结果不存在!"<<endl;
exit(1);
}
for(int i=1;i<index-1;i++)
m_head=m_head->next;
cout<<"你要查找的姓名是:"<<m_head->Name<<endl<<"学号是:"<<m_head->No<<endl;
}
void bublle(int a[],int n) //冒泡排序
{ int i,j,t,temp;
for(i=1;i<=n-1;i++)
{ t=n-1;
for(j=0;j<t-1;j++)
{ if (a[j]>a[j+1])
{ temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
}
}

};


void main()
{}

还有6个错,帮我看看吧……


冬天的梦想是我在春天的愿望^^
2006-12-18 08:55



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




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

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