- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
考虑以下测试1代码
struct A {
private:
class face;
friend class face;
};
struct A::face {};
template <typename _CharT>
struct C : public A::face
{};
int main()
{
C<int> x;
}
这段代码格式正确吗?我在 g++ 和 comeau 下测试了它。 g++ 可以很好地编译它,而 comeau 会给出以下错误消息(我认为这是正确的)
"ComeauTest.c", line 12: error: class "A::face" (declared at line 9) is inaccessible
struct C : public A::face
^
detected during instantiation of class "C<_CharT> [with _CharT=int]"
at line 17
在这种情况下哪个编译器是正确的? Comeau 是我所知道的最符合标准的编译器之一。 g++又错了吗?
(1) 这不是真实的代码。
最佳答案
这是不正确的。 face
是私有(private)的,所以它不能从 C 访问。只有当 C 是 A 的好友时,这才是合法的,而不是 face
。 face
是私有(private)成员,因此 friend
对它无效。
关于c++ - Comeau vs g++ [又一个错误],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8538067/
为什么我们不能使用这样的东西 struct { int bar; } Foo; int main() {} 在 C++ 模式的 Comeau 编译器中,而在 C 模式下我们可以吗? "Come
我正在尝试使用 SFINAE 来检测类是否具有采用特定类型的重载成员函数。我的代码似乎可以在 Visual Studio 和 GCC 中正常工作,但无法使用 Comeau 在线编译器进行编译。 这是我
考虑以下测试1代码 struct A { private: class face; friend class face; }; struct A::face {}
到目前为止,我一直在使用 gcc、g++ 进行 C、C++ 应用程序开发,并且发现它非常棒。但是浏览 Stack Overflow 我发现许多成员表示 Comeau 编译器中的错误报告比任何其他编译器
考虑以下代码: template class base {}; int main() { base test; return 0; } Comeau 和 MSVC 都可以毫无问题地编译
这是测试代码 template void f() { T t; t.f(0); //compiles even without the "template" keyword, what am
我有几个关于 C++ 编译器的问题 C++ 编译器是否需要 one-pass compiler ?标准是否在任何地方谈论它? 特别是 GCC 是一次性编译器吗?如果是,那么为什么它会在 this ex
我是一名优秀的程序员,十分优秀!