点列表编译异常了
点列表编译错误了。求助
//PointlList.h
const int maxListSize=10;
class Point
{
public:
Point(float x0=0,float y0=0)
{
x=x0;y=y0;
}
float x,y;
};
class PointList()
{
public:
PointList();
void append(Point newPoint);
void clear();
bool isEmpty() const;
bool isFull() const;
void gotoBeginning();
void gotoEnd();
bool gotoNext;
bool gotoPrior();
Point getCursor() const;
void printPoint(Point a);
void showStructure() const;
private:
int size,cursor;//cursor is the index of a point array
Point points[maxListSize];
};
//PointList.cpp
#include <iostream>
#include "PointList.h "
using namespace std;
PointList::PointList()
{
points[maxListSize];
cursor=null;
size=0;
}
void PointList::append(Point newPoint)
{
if(size <=maxListSize)
{
if(cursor==null)
{
points[0]=newPoint;
cursor=0;
}
else {
points[cursor+1]=newPoint;
cursor++;
}
size++;
}else
cout < < "The list is too full to add a new point. " < <endl;
}
void PointList::clear()
{
int i=0;
while(i=0;i <cursor+1;i++)
{
points[i].x=null;
points[i].y=null;
}
size=0;
curse=null;
}
bool PointList::isEmpty() const
{
return size==0;
}
bool PointList::isFull() const
{
return size==maxListSize;
}
void PointList::gotoBeginning()
{
cursor=0;
}
void PointList::gotoEnd()
{
cursor=size-1;
}
bool PointList::gotoNext()
{
if((cursor!=size-1)&&(size!=0))
{
cursor=cursor++;
return true;
}
else return false;
}
bool PointList::gotoPrior()
{
if((cursor!=0)&&(size!=0))
{
cursor--;
return true
}else return false;
}
Point PointList::getCursor() const
{
return points[curse];
}
void PointList::printPoint(Point a)
{
cout < < "( " < <a.x < < ", " < <b.x < < ") " < <endl;
}
void PointList::showStructure() const
{
if(size==0)
cout < < "Empty list. " < <endl;
else{
int i=0;
while(i=0;i <size;i++)
{
printPoint(points[i]);
}
}
}
大致有三类错误:
1.PointList is not a class
2.modifiers are not allowed on nonemember function
3.missing ; before{
都是莫名奇怪的错误。
谢谢大牛,不胜感激~
------解决方案--------------------
//PointlList.h
const int maxListSize=10;
class Point
{
public:
Point(float x0=0,float y0=0)
{
x=x0;y=y0;
}
float x,y;
};
class PointList()
{
public:
PointList();
void append(Point newPoint);
void clear();
bool isEmpty() const;
bool isFull() const;
void gotoBeginning();
void gotoEnd();
bool gotoNext;
bool gotoPrior();
Point getCursor() const;
void printPoint(Point a);
void showStructure() const;
private:
int size,cursor;//cursor is the index of a point array
Point points[maxListSize];
};
//PointList.cpp
#include <iostream>
#include "PointList.h "
using namespace std;
PointList::PointList()
{
points[maxListSize];
cursor=null;
size=0;
}
void PointList::append(Point newPoint)
{
if(size <=maxListSize)
{
if(cursor==null)
{
points[0]=newPoint;
cursor=0;
}
else {
points[cursor+1]=newPoint;
cursor++;
}
size++;
}else
cout < < "The list is too full to add a new point. " < <endl;
}
void PointList::clear()
{
int i=0;
while(i=0;i <cursor+1;i++)
{
points[i].x=null;
points[i].y=null;
}
size=0;
curse=null;
}
bool PointList::isEmpty() const
{
return size==0;
}
bool PointList::isFull() const
{
return size==maxListSize;
}
void PointList::gotoBeginning()
{
cursor=0;
}
void PointList::gotoEnd()
{
cursor=size-1;
}
bool PointList::gotoNext()
{
if((cursor!=size-1)&&(size!=0))
{
cursor=cursor++;
return true;
}
else return false;
}
bool PointList::gotoPrior()
{
if((cursor!=0)&&(size!=0))
{
cursor--;
return true
}else return false;
}
Point PointList::getCursor() const
{
return points[curse];
}
void PointList::printPoint(Point a)
{
cout < < "( " < <a.x < < ", " < <b.x < < ") " < <endl;
}
void PointList::showStructure() const
{
if(size==0)
cout < < "Empty list. " < <endl;
else{
int i=0;
while(i=0;i <size;i++)
{
printPoint(points[i]);
}
}
}
大致有三类错误:
1.PointList is not a class
2.modifiers are not allowed on nonemember function
3.missing ; before{
都是莫名奇怪的错误。
谢谢大牛,不胜感激~
------解决方案--------------------