自动更改指向函数的指针的名称
Change name of a Pointer to function automatically
我想自动更改指向函数的指针的名称,在本例中,指向函数的指针的名称为"CImageGraph",如下所示。例如,我希望指针名称为"pGraph"加上循环索引"ttt";然而,我得到错误。那么,自动更改指针名称的最佳方法是什么呢?谢谢。
const word nStates = 9;
const int T = 6;
const int nState = 2;
for(int ccc = 0; ccc < nStates; ccc++){
for(int ttt = 0; ttt < T; ttt++){
string pGraph = "pGraph"+ttt;
CImageGraph *pGraph = new CImageGraph(nState);
}
}
所以我设法找到一个解决方案使用数组,感谢提示。解决方案如下:
const word nStates = 9;
const int T = 6;
const int nState = 2;
for(int ccc = 0; ccc < nStates; ccc++){
CImageGraph **pGraph = new CImageGraph*[T];
for(int ttt = 0; ttt < T; ttt++){
pGraph[ttt] = new CImageGraph(nState);
//Other processes
}
}
相关文章:
- 如何正确编写指针函数声明?
- C++常规指针函数或模板
- 如何重新定义 C++ 指针函数?
- C++ 指向其他类函数的指针函数
- 指针到指针函数参数
- 将指向成员的指针函数传递到模板中
- C++ 在 none 常量指针函数中返回一个常量指针
- 如何使用指针函数编写/读取数组
- 是C 中的函数指针函数对象
- 如何从另一个类调用指向成员的指针函数
- 如何声明采用指向成员的指针函数的函数
- 如何构造一个以可变参数指针函数作为成员的类?
- c 通过值或指针函数语法
- 将typedef方法作为指针函数传递
- 从 Main 中的双指针函数打印出指针数组
- strcpy 对指针函数的引用
- 这是否仍然声明一种指针函数的别名?
- 将指向成员的指针函数与 std::shared_ptr 结合使用
- 'Incomplete type' 为标准::函数声明指向成员的指针函数模板参数时出错
- 从注入进程的 DLL 调用函数并更改指针函数的地址