pointers - c++ combine singleton and visitor pattern -
i'm having problem pointers. background java , i've still not got hand of using pointers. error is:
syntax error: identifier 'stockcontroller'
from line:
virtual void visit(stockcontroller* stock) = 0;
i've implemented singleton. i'm looking add visitor pattern. have series of operations ill applying 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 instance of class */ static stockcontroller* getinstance(); protected: /* prevent initialisation unless through 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
Comments
Post a Comment