【发布时间】:2012-12-07 16:48:10
【问题描述】:
对不起,如果这是一个琐碎的问题:
实施 1:
class Foo
{
protected: int bar;
public: Foo(int bar)
{
this->bar =bar;
}
};
实施 2:
class Foo
{
protected: int bar;
public: Foo(int bar)
{
this.bar =bar;
}
};
实施 2 的输出:
request for member ‘x’ in ‘this’, which is of pointer type ‘Foo* const’ (maybe you meant to use ‘->’ ?)
所以this是一个指针,而this问题在代码中有语法错误
【问题讨论】:
-
这是基本的东西——(原始)指针只能用于
->,不能用于.。 -
仅供参考 -
C++和C#是 2 种不同的语言。 -
我来自 Java。 @user93353 的翻译中丢失了一些东西,代码标记为 C++ && C#。我的坏虽然
-
@aiao:我已经从链接的问题中删除了 C++ 标签,因为代码显然不是 C++