English 中文(简体)
c++ 汇编错误
原标题:c++ compilation error

i got a compile error which i do not understand. i have a h/cpp file combination that does not contain a class but just defines some utility functions. when i try to use a struct that is defined in another class i get the error:

C2027错误:使用未定义的B类:C

因此,被 stripped弄到问题,藏书认为情况如此。

namespace A {
    void foo(B::C::SStruct const & Var);
}

标准结构的定义属于另一卷,当然包括。

namespace B {
    class C {
        public:
        struct SStruct { };
    };
}

the strange thing is, i can use this struct in other classes fine, it just seems to be related to this one h-file which contains just utility functions. what am i missing here? thanks!

最佳回答

在纠正失踪的半殖民地之后,这汇编了:

namespace B {
    class C {
        public:
        struct SStruct { };
    };
}
namespace A {
    void foo(B::C::SStruct const & Var);
}

显然,如果两个名称空间的次序被改变,那不会奏效。 也许你只是大错的头脑。 如果这是错误,那么这种错误设计就不正确了,那么你就不应允许标题在你的法典中处理。

问题回答

我假定你指的是“C类”,而不是“Class C”。

struct SStruct is private to category C ( private being theailprofile of category members).

因此,在C类及其朋友之外,这并不明显,其中包括A:foo(......)。

Class C { 
        struct SStruct { }; 
    } 

=>

class C { 
public:
        struct SStruct { }; 
    };

在定义之后,你的阶级就失去了一个半殖民地。 应当:

namespace B {
    class C {
        public:
        struct SStruct { };
    }; // <=== Here
}




相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?

热门标签