简体   繁体   English

C ++-“不允许不完整的类型”错误是什么意思,我该如何解决?

[英]C++ - What does “Incomplete type not allowed” error mean, and how can I fix it?

Although I've seen many questions referring to the "Incomplete type not allowed" error in C++, I still cannot figure out what the compiler is trying to tell me when it screams at me like this. 尽管我已经看到很多关于C ++中“不允许输入不完整类型”错误的问题,但我仍然无法弄清楚编译器在向我这样大叫时试图告诉我什么。 I've been able to piece together that it has something to do with #include -ing header files, but I am clueless as to what an "incomplete type" is and why it is "not allowed". 我已经能够弄清楚它与#include -ing头文件有关,但是对于“不完整类型”是什么以及为什么“不允许”它一无所知。 I got the error when trying to inherit from SDL_Window as such: 尝试从SDL_Window继承时出现错误:

#pragma once
#include "SDL.h"

class Window : public SDL_Window
{
public:
  Window();
  ~Window();
};

Could someone please explain to me what the error means, how to (generally) fix it, and, in my case, what I should do to stop it from happening? 有人可以向我解释该错误是什么意思,如何(通常)修复它,就我而言,我应该怎么做才能阻止它发生?

C++ - What does “Incomplete type not allowed” error mean C ++-“不允许不完整的类型”错误是什么意思

Incomplete type means that there is no definition for the type SDL_Window . 类型不完整意味着没有定义SDL_Window类型。

The error means that the type is incomplete, and that an incomplete type wasn't allowed in that context. 该错误表示该类型不完整,并且在该上下文中不允许使用不完整的类型。 In this particular case: an incomplete type cannot be used as a base class. 在这种特殊情况下:不完整的类型不能用作基类。

what I should do to stop it from happening? 我应该怎么做才能阻止它的发生?

Do not attempt to use SDL_Window as a base class - it is not intended to be used in that way. 不要尝试将SDL_Window用作基类-不应以这种方式使用它。

SDL_Window is intended to be used as an opaque pointer. SDL_Window旨在用作不透明的指针。 Some SDL functions may return you a SDL_Window* . 某些SDL函数可能会返回SDL_Window* You can store it, and send it as an argument to other SDL functions. 您可以存储它,并将其作为参数发送给其他SDL函数。 That is all it is used for. 这就是它的全部用途。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 “不完整类型不允许”错误是什么意思? - What does the “incomplete type is not allowed” error mean? 我该如何解决C ++中的不完整类型错误? - How can i solve the incomplete type error in c++? 不允许使用C ++不完整类型 - C++ Incomplete type is not allowed C ++:声明对象时“不允许使用不完整的类型”-原因是什么? - C++: “incomplete type is not allowed” when declaring an object - What is the cause? 不完整的类型,这是什么意思? - Incomplete type, what does this mean? 我怎么知道是什么原因导致错误的不完整类型不完整:对指向不完整类型的指针进行算术运算 - How can I know what makes an incomplete type incomplete for error: arithmetic on a pointer to an incomplete type 错误:不允许指向不完整类类型的指针。 SDL / c ++ - Error: Pointer to incomplete class type is not allowed. SDL/c++ C ++前向声明和“不允许不完整类型”错误 - C++ Forward declaration and 'Incomplete type is not allowed' error 如何修复虚幻引擎 4 中的“不允许指向不完整类类型的指针”错误 - How to fix "Pointer to Incomplete class type is not allowed" error in Unreal Engine 4 使用了 C++ 异常处理程序,但未启用展开语义:这是什么意思,我该如何解决? - C++ exception handler used, but unwind semantics are not enabled: What does it mean, and how do I fix it?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM