诸如class bar *bar之类的指针的名称是什么?



一个简单的示例:

void foo(class Bar * bar) {
    foo2(bar);
}
void foo2(Bar * bar) {
    bar->a++;
}

FOO2中使用的指针是指向类栏的标准指针。好的 - FOO中使用的指针也是指向类栏的指针。但是在这个地方不得知道班级栏。

我找不到正确的foo命名。这是指向匿名类的指针吗?class Bar *bar的正确名称是什么?

您需要的是forward declaration

您可以在文档或其他帖子中阅读有关它的信息。

来自文档:

Declares a class type which will be defined later in this scope. Until the definition appears, this class name has incomplete type. This allows classes that refer to each other.

我将其称为 inline forward class class声明,但我认为这没有特殊名称。

它只是告诉有一个Bar类,因此可以在此范围中使用。

不能这样做Bar的呼叫成员。它说的只是,它没有说出它是什么。Bar是A 不完整的类型喜欢。

最新更新