Answer the question
In order to leave comments, you need to log in
How to use forward declaration?
Hello! I recently learned about forward declaration and a question appeared: I have a Log.h file, with the following "skeleton":
Log.h
class LogCollapserMaker
{
public:
class LogCollapser
{
public:
LogCollapser(uint32_t estimateCount);
bool estimated();
private:
boost::recursive_mutex m_collapserMutex;
const uint32_t m_estimateCount;
uint32_t m_count;
};
public:
typedef boost::shared_ptr<LogCollapser> LogCollapserSP;
LogCollapserSP logCollapser(const std::string& key, uint32_t estimateCount);
private:
boost::recursive_mutex m_mutex;
std::map<std::string, LogCollapserSP> m_logCollapserMap;
};
Answer the question
In order to leave comments, you need to log in
ATTENTION! This is a bad example, don't do it!
//fwd
class LogCollapserMaker;
LogCollapserMaker * GetLog(); // в срр реализация функции
// fwd только для того, чтобы объявить эту функцию до объявления класса
class LogCollapserMaker
{
public:
class LogCollapser
...
};
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question