我的问题很简单:C++中的void指针是什么?(你声明的那些东西void* myptr;)
它们的用途是什么?我可以让它们指向任何类型的变量吗?
我正在写一些性能关键的东西,想知道如果我使用它是否会有所作为:
int test( int a, int b, int c )
{
// Do millions of calculations with a, b, c
}
Run Code Online (Sandbox Code Playgroud)
要么
class myStorage
{
public:
int a, b, c;
};
int test( myStorage values )
{
// Do millions of calculations with values.a, values.b, values.c
}
Run Code Online (Sandbox Code Playgroud)
我确信这对C++专家来说很明显,所以我现在不会尝试为它写一个不切实际的基准