久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

c ++ struct 未命名類型

c++ struct does not name a type(c ++ struct 未命名類型)
本文介紹了c ++ struct 未命名類型的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我在頭文件中定義一個結構,然后在相應的 .cpp 文件中設置其成員.為此,我使用了一個函數,該函數應該在其范圍內創建一個(相同的)結構,然后返回它.像這樣:

I am defining a structure in a header file, and then setting its members in the corrosponding .cpp file. For doing this I am using a function that is supposed to create a (same) structure in its scope, and then return it. Something like this:

在標題中:

#include <things>
class GLWindow : public QGLWidget, public QGLFunctions
{
    Q_OBJECT
public:
    GLWindow(QWidget *parent = 0);
    ~GLWindow();

    //....
    struct Drawable
    {
        GLuint     vertexBuffer;
        GLuint     indexBuffer;
        int        faceCount;
        QMatrix4x4 transform;
    }cube;
    GLuint cubeTex;

    Drawable CreateDrawable(GLfloat* C_vertices, GLfloat* C_tex, GLfloat* C_normals, GLushort* C_facedata, int faces);
    //.....
};

在 cpp 文件中:

#include "glwindow.h"

Drawable GLWindow :: CreateDrawable(GLfloat *C_vertices, GLfloat *C_tex, GLfloat *C_normals, GLushort *C_facedata, int faces)
{
    int faceCount =faces;

    QMatrix4x4 Transform;
    Transform.setToIdentity();

    GLuint VB;
    /*Create vertexbuffer...*/

    GLuint IB;
    /*Create indexbuffer...*/

    Drawable drawable;
    drawable.faceCount = fCount;
    drawable.transform = Transform;
    drawable.vertexBuffer = VB;
    drawable.indexBuffer = IB;

    return drawable;
}

void GLWindow :: someOtherFunction()
{
    //.....
    cube = CreateDrawable(cube_vertices, cube_tex, cube_normals, cube_facedata, cube_face);
    //.....
}

我收到一個錯誤,指出 'Drawable' 沒有命名類型,但我不明白為什么我會收到這個錯誤,或者我可以做些什么來消除它.>

I am getting an error stating that 'Drawable' does not name a type, but I can't comprehend why I am getting this error, or what I can do to eliminate it.

推薦答案

你需要在cpp文件中限定Drawable:

You need to qualify Drawable in the cpp file:

GLWindow::Drawable GLWindow :: CreateDrawable(GLfloat *C_vertices, GLfloat *C_tex, GLfloat *C_normals, GLushort *C_facedata, int faces)

在 cpp 文件中,在成員方法之外,您在類上下文之外進行操作.在方法內部你可以使用Drawable,但在外部(包括返回類型),你需要使用GLWindow::Drawable.

In the cpp file, outside the member methods, you're operating outside the class context. Inside the methods you can use Drawable, but outside (including return type), you need to use GLWindow::Drawable.

如果你實際上從方法中返回了一個 Drawable,而不是一個 void - 也是一個錯誤.

That's if you're actually returning a Drawable from the method, not a void - also an error.

這篇關于c ++ struct 未命名類型的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

How can I read and manipulate CSV file data in C++?(如何在 C++ 中讀取和操作 CSV 文件數據?)
In C++ why can#39;t I write a for() loop like this: for( int i = 1, double i2 = 0; (在 C++ 中,為什么我不能像這樣編寫 for() 循環: for( int i = 1, double i2 = 0;)
How does OpenMP handle nested loops?(OpenMP 如何處理嵌套循環?)
Reusing thread in loop c++(在循環 C++ 中重用線程)
Precise thread sleep needed. Max 1ms error(需要精確的線程睡眠.最大 1ms 誤差)
Is there ever a need for a quot;do {...} while ( )quot; loop?(是否需要“do {...} while ()?環形?)
主站蜘蛛池模板: 亚洲午夜av | 三级在线视频 | 色www精品视频在线观看 | 成人精品在线观看 | 成人福利 | 欧美日韩一区二区在线播放 | www.久久精品视频 | 国产农村妇女毛片精品久久麻豆 | 日韩三级一区 | 日韩视频一区二区 | 欧美a区 | 国产三区视频在线观看 | 日韩在线看片 | 亚洲一区二区中文字幕 | 久久久久久久久国产精品 | 免费看黄视频网站 | 久久久久久综合 | 狠狠操电影 | 欧美激情亚洲激情 | 亚洲视频区 | 99久久国产 | 日韩一区二区三区精品 | 日批免费看 | 在线视频日韩精品 | 97国产精品 | 久久国产精品色av免费观看 | 99re国产视频 | 久久国际精品 | 精品日韩 | 一区二区三区回区在观看免费视频 | 国产精品福利网 | 欧美嘿咻 | 欧美精品一区在线发布 | 精品久久久久久久久亚洲 | 成人中文字幕在线观看 | 中文字幕第十一页 | 99久久婷婷国产综合精品电影 | 男女黄网站 | 国产成人小视频 | 欧美视频免费在线观看 | 中文字幕人成人 |