Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 26th, 2012  |  syntax: None  |  size: 1.42 KB  |  hits: 12  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. compile errors in singleton inside head file
  2. #ifndef POINTPOOL_H_
  3. #define POINTPOOL_H_
  4.  
  5. #include <list>
  6. #include <iostream>
  7.  
  8. #include "ofPoint.h"
  9.  
  10. // adapted from https://gist.github.com/1124832
  11.  
  12. class PointPool
  13. {
  14.     private:
  15.         std::list<ofPoint*> resources;
  16.         static PointPool* instance;
  17.  
  18.         PointPool() {};
  19.  
  20.     public:
  21.         ~PointPool() {};                      // 1
  22.         static pointPool* getInstance()       // 2
  23.         {
  24.             if (instance == 0)
  25.             {
  26.                 instance = new PointPool();
  27.             }
  28.             return instance;
  29.         }
  30.  
  31.         Resource* getPoint()
  32.         {
  33.             if (resources.empty())
  34.             {
  35.                 std::cout << "Creating new." << std::endl;
  36.                 return new ofPoint();
  37.             }
  38.             else
  39.             {
  40.                 std::cout << "Reusing existing." << std::endl;
  41.                 ofPoint* resource = resources.front();
  42.                 resources.pop_front();
  43.                 return resource;
  44.             }
  45.         }
  46.  
  47.         void disposePoint(ofPoint* object)
  48.         {
  49.             object->x = 0;
  50.             object->y = 0;
  51.             object->z = 0;
  52.             resources.push_back(object);
  53.         }
  54. };
  55.  
  56. PointPool* PointPool::instance = 0;
  57.  
  58. #endif /* POINTPOOL_H_ */
  59.        
  60. expected unqualified-id at end of input
  61.        
  62. expected ‘;’ before ‘*’ token
  63.        
  64. static pointPool* getInstance()
  65.        
  66. static PointPool* getInstance()