gpt4 book ai didi

c++ - C++ 类中类的语法

转载 作者:行者123 更新时间:2023-11-30 01:29:47 25 4
gpt4 key购买 nike

如果我有以下内容

class A
{
public:
int stuff;
void helper(B temp, int d); //what about here? I'm getting a 'B' has not been declared error here.
private:
class B
{
public:
int stuffer;
private:
int x;
};
}:

在我的实现文件中引用类 2 的正确方法是什么?可不可能是1::2::someMethod?还是 2::someMethod

最佳答案

假设 1 和 2 引用真实的类名,1::2::methodName 就像任何其他嵌套作用域一样。

关于c++ - C++ 类中类的语法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5327666/

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