C++:类型定义和嵌套类问题
C++: typedefing and nested class issue
我有:
class ThreadPool
{
public:
....
private:
struct TP_Thread: public Thread_t
{
....
};
std::vector<std::tr1::shared_ptr<TP_Thread> > m_threads;
.....
};
我想做一些类似的事情:
typedef std::tr1::shared_ptr<TP_Thread> shpThread;
以缩短类定义中的书写。问题是,我要么得到指向不完整类型的指针(因为类之前的前向声明和公共部分的typedef),要么试图访问ThreadPool的私有成员(在我试图在类之外对其进行typedef的情况下)。我如何对其进行typedef,以便在实现过程中自由使用它?
为什么不将typedef包含在类的公共部分中:
class ThreadPool
{
public:
....
private:
struct TP_Thread: public Thread_t
{
....
};
public:
typedef std::tr1::shared_ptr<TP_Thread> Shp;
...
然后在代码中使用ThreadPool::Shp
。
相关文章:
- 嵌套for循环C++的问题(初学者)
- 嵌套While循环不起作用(C++问题)
- 超级对撞机2D阵列:生成嵌套:包装/尺寸问题
- 为什么使用 2 个嵌套循环 O(n^2) 复杂度来解决二和问题,当只改变循环计数器逻辑时运行得更快?
- c++在实现模板化嵌套类时遇到问题
- 如果不是这样,我需要帮助理解这个嵌套的问题
- 嵌套的类成员变量不可访问.链表设置.V、下一个和新的问题
- 按升序对数组进行排序嵌套循环问题
- C++中嵌套在另一个 LinkedList 中的 LinkedList 整数上的回调函数问题
- 循环时嵌套有任何问题
- 这个嵌套循环C++有什么问题?
- 跳跃游戏中嵌套的循环问题
- 嵌套模板化类的问题
- 访问嵌套类中的变量时出现问题
- C++ 嵌套构造函数调用问题
- 嵌套类模板专用化问题
- C 嵌套的Coroutine破坏问题
- 嵌套模板问题C++
- C 完美的数字,带有嵌套循环问题
- 嵌套 while 循环,包含文件 c++ 问题