I have this error but cant seem to see why. This code compiled would give 1 error. Anyone please advise, thanks.
#include <string>
using namespace std;
class Beverage{
protected:
Beverage *beverage;
string desc;
public:
friend class Bev_Iterator;
Beverage(){
beverage = 0;
desc = "unknown beverage";
}
virtual string getdesc(){
return desc;
}
virtual double cost(){
return 0;
}
Bev_Iterator* Iterator();
};
Bev_Iterator* Beverage::Iterator(){
return new Bev_Iterator((Beverage*) this); //error here
};
class Bev_Iterator{
Beverage *bev, *next;
public:
Bev_Iterator(Beverage *bev){
this->bev=bev;
}
void moveFirst(){
next=bev;
}
Beverage *Next(){
Beverage *t=next;
next=next->Beverage;
return t;
}
bool hasNext(){
return (next!=0);
}
};