我有指针和引用与std :: vector和std :: string的具体问题。一些问题在下面的代码中被剪下,一些在下面。C++,指针,引用,从一个到另一个函数,std :: vector,std :: string
我有基本的代码
//first of all: is this function declaration good?
//or shoudl I already pass the std::vector in another way?
//I'm only reading from it
void func(const std::vector<std::string>& vec)
{
//I need to call otherFunc(void*) with a single element from vec:
//otherFunc(void* arg);
//with arg being a void* to vec[0]
}
我的IDE告诉我,只有&*vec[0]
作品参数otherFunc
,但这并不编译...
如何是最好的方式做这些一种参数传递?
你需要解释你想传递给函数的东西。它自己的“void *”是没有意义的。要使用“void *”,您必须首先将其转换为其他类型。那么,“void *”函数的功能是什么? – user9876
我不知道,因为它来自外部库。我不能改变'otherFunc(void *)',我只能改变我自己的'func()'。 – blubberbernd