C ++ - 错误C4430:缺少类型说明符(对于构造函数???)

时间:2013-01-20 21:27:05

标签: c++

自昨晚以来,我一直坚持这一点,而对于我的生活,我一直无法弄清楚为什么会这样。我必须遗漏一些非常简单的东西。

我正在制作一个OpenGL程序。在这个程序中,我正在制作一个DialogBox类。以下是代码:

//---------------------------------------------------------------
//DialogBox.h
//---------------------------------------------------------------

#include <vector>

class DialogBox
{
    private:

      float X; float Y; float Z;
      float Width;
      float Height;

      float RED;
      float GREEN;
      float BLUE;
      float ALPHA;

      int currentLine; 
      int maxLines;    //How many lines of text this dialog box can hold
      int maxChars;    //How many chars each line of text can hold

      std::vector< std::vector<char> >Text; //Text contents of the Dialog Box

      unsigned int vertexArray_DialogBox;
      unsigned int vertexBuffer_DialogBox;


   public:

      DialogBox();
      DialogBox(float width, float height);

      void draw();
      void draw(float x, float y, float z);

};

//------------------------------------------------------------------------
//DialogBox.cpp
//------------------------------------------------------------------------

#include <iostream>
#include "DialogBox.h"

DialogBox::DialogBox()
{
    X = 0.0f; Y = 0.0f; Z = 0.0f;

    Width = 1.0f;
    Height = 1.0f;

    RED = 0.0f;
    GREEN = 1.0f;
    BLUE = 1.0f;
    ALPHA = 1.0f;

    //For HELVETICA_18 ----------------------
    static const float letter_width = 0.03f;
    static const float letter_height = 0.04f;
    static const float line_height = 0.1f;
    //---------------------------------------


   maxLines = Height / line_height - 4; 
   maxChars = Width / letter_width - 2; 

   Text.resize(maxLines);
   for(int i = 0; i < maxLines; i++)
   {
       Text[i].resize(maxChars);
   }
}

DialogBox::DialogBox(float width, float height)
{
    Width = width;
    Height = height;
    //The rest of the initialization codes
}

void DialogBox::draw()
{
    //OpenGL Drawing codes
}

void DialogBox::draw(float x, float y, float z)
{
    X = x; Y = y; Z = z;
    draw();
}

编译器抛出了此错误消息:

enter image description here

我一直在拉我的头发,但我无法弄清楚编译器指的是什么。它必须是非常简单的东西(如代码中的拼写错误或类似的东西)。提前感谢您的帮助。

3 个答案:

答案 0 :(得分:7)

同一条线上的警告是什么?

  

宏'DialogBoxA'的实际参数不够

DialogBox#define - d宏吗?如果是这样,那可能会搞砸了。

答案 1 :(得分:3)

当我编译代码时,我在DialogBox::draw()上收到错误,因为你没有在那里指定返回类型。具体来说,这是在实施,而不是声明。这是我在代码中发现的唯一编译器错误。也许您的编译器只是标记错误的行?

答案 2 :(得分:3)

Microsoft已经提供了一个名为DialogBox的函数(宏?): http://msdn.microsoft.com/en-us/library/windows/desktop/ms645452%28v=vs.85%29.aspx

可能是<iostream><vector>或其他任何内容。将您的班级重命名为更原始的名称应该会有所帮助。