I'm having a problem with pointers. My background is Java and I've still not got the hand of using pointers. My error is:
syntax error: identifier 'StockController'
from this line:
virtual void visit(StockController* stock) = 0;
I've implemented my singleton. But now i'm looking to add the visitor pattern. I have a series of operations ill be applying to the collection of objects.
Visitor abstract class:
#ifndef VISITOR_H
#define VISITOR_H
#include "StockController.h"
class Visitor
{
public:
virtual void visit(StockController* stock) = 0;
};
#endif
Singleton class:
#ifndef StockController_H
#define StockController_H
#include <iostream>
#include "Visitable.h"
using namespace std;
class StockController : public Visitable {
public:
/*Returns an instance of the class */
static StockController* getInstance();
protected:
/* Prevent initialisation unless through get method */
StockController();
StockController(const StockController&);
StockController& operator= (const StockController&);
private:
/* Class instance */
static StockController* _instance;
};
#endif
Visitable.h:
#ifndef VISITABLE_H
#define VISITABLE_H
#include "Visitor.h"
class Visitable {
public:
virtual void accept(Visitor &visitor) = 0;
};
#endif
Aucun commentaire:
Enregistrer un commentaire