C ++: Unknown pointer size in direct declaration (error C2036)

In the header file, I declared two namespace elements:

namespace Foo {
    struct Odp
    typedef std::vector<Odp> ODPVEC;
};

class Bar
{
public:
     Foo::ODPVEC baz; // C2036
};

Error generated by the compiler:

error C2036: 'Foo::Odp *': unknown size

I assume this is a problem with the forward announcing Odp. How can I get around this?

+3
source share
2 answers

Do not forward the announcement Odp. The compiler does not know what type std::vector<Odp>is because it Odphas not yet been declared. Give the compiler a complete declaration for this class.

+3
source

std::vector , , , , , . , , :

class foo;
typedef std::vector<foo*> foo_ptr_vec;

.

+3

Source: https://habr.com/ru/post/1750026/


All Articles