C类范围包括哪些内容呢?
- 内容介绍
- 文章标签
- 相关推荐
本文共计187个文字,预计阅读时间需要1分钟。
我是从Objective-C转到C,并遇到了问题……这有效:- function1(char *filePath) { Box box(filePath); // construct/create a box using filePath // can use box in this function and destructor is called when function exits } 但我需要‘’
我是从Objective C来到C并遇到问题……这有效: –
function1(char *filePath) { Box box(filePath); // construct/create a box using filePath // can use box in this function and destructor is called when function exits }
但是我需要这样的东西,其中function1和function2是异步调用的.
Box *boxPool[25]; // a pool of 25 box pointers function1(int item, char *filePath) { boxPool[item](filePath); // construct/create a box, store a pointer in boxPool that is retained on exit } function2(int item) { // use the box from boxPool[item] and then destruct/release it on exit } 也许:
void function1(int item, char *filePath) { boxPool[item] = new Box(filePath); } void function2(int item) { //use boxPool[item] delete boxPool[item]; boxPool[item] = NULL; }
本文共计187个文字,预计阅读时间需要1分钟。
我是从Objective-C转到C,并遇到了问题……这有效:- function1(char *filePath) { Box box(filePath); // construct/create a box using filePath // can use box in this function and destructor is called when function exits } 但我需要‘’
我是从Objective C来到C并遇到问题……这有效: –
function1(char *filePath) { Box box(filePath); // construct/create a box using filePath // can use box in this function and destructor is called when function exits }
但是我需要这样的东西,其中function1和function2是异步调用的.
Box *boxPool[25]; // a pool of 25 box pointers function1(int item, char *filePath) { boxPool[item](filePath); // construct/create a box, store a pointer in boxPool that is retained on exit } function2(int item) { // use the box from boxPool[item] and then destruct/release it on exit } 也许:
void function1(int item, char *filePath) { boxPool[item] = new Box(filePath); } void function2(int item) { //use boxPool[item] delete boxPool[item]; boxPool[item] = NULL; }

