這是我的課:編譯錯誤
#ifndef POINTPOOL_H_
#define POINTPOOL_H_
#include <list>
#include <iostream>
#include "ofPoint.h"
// adapted from https://gist.github.com/1124832
class PointPool
{
private:
std::list<ofPoint*> resources;
static PointPool* instance;
PointPool() {};
public:
~PointPool() {}; // 1
static pointPool* getInstance() // 2
{
if (instance == 0)
{
instance = new PointPool();
}
return instance;
}
Resource* getPoint()
{
if (resources.empty())
{
std::cout << "Creating new." << std::endl;
return new ofPoint();
}
else
{
std::cout << "Reusing existing." << std::endl;
ofPoint* resource = resources.front();
resources.pop_front();
return resource;
}
}
void disposePoint(ofPoint* object)
{
object->x = 0;
object->y = 0;
object->z = 0;
resources.push_back(object);
}
};
PointPool* PointPool::instance = 0;
#endif /* POINTPOOL_H_ */
我得到
expected unqualified-id at end of input
在註釋1和
expected ‘;’ before ‘*’ token
在評論2我試圖谷歌,但我不認爲這個編譯器消息錯誤和我的代碼之間的鏈接..
Singleton ???????爲什麼??????????????????? – 2012-02-26 01:15:58