gpt4 book ai didi

c++ - 发送指向函数的指针

转载 作者:行者123 更新时间:2023-11-30 04:10:26 27 4
gpt4 key购买 nike

我想发送一个指向函数的指针,我的问题是当我尝试将指针的内存地址发送给该函数时,它迫使我像 ** 一样声明第二个函数的参数。

void MaterialParser::processMaterialTexture(vector<string>* params, MaterialTexture* texture){
for (int i = 0; i < params->size(); i++){
if((*params)[i]=="-o"){
proccesOST(&texture,&params,i);
}
}
}
void MaterialParser::proccesOST(MaterialTexture* texture ,vector<string>* params,int index){
//function

当我调用函数时,抛出以下错误,参数 MaterialTexture** 与参数 MaterialTexture* 不兼容。

proccesOST(&texture,&params,i);

如果我像这样声明函数:

void MaterialParser::proccesOST(MaterialTexture** texture ,vector<string>** params,int index){

如何访问变量?或者更好的是,我怎样才能将参数发送为仅指针而不是双指针?

最佳答案

省略函数调用中的&。你的纹理已经是一个指针。 & 运算符创建一个指向其背后内容的指针,在这种情况下您不想这样做。

关于c++ - 发送指向函数的指针,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20629501/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com