1

I've been stuck with this since last night, and for the life of me, I haven't been able to figure out why this is happening. I must be missing something very simple.

I'm making an OpenGL program. In this program, I'm making a DialogBox class. Below is the code:

//---------------------------------------------------------------
//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();
}

And the compiler threw this error message:

enter image description here

I have been pulling my hairs out, but I couldn't figure out what the compiler were referring to. It must be something really simple (like a typo in the codes or something like that). Thank you in advance for your help.

4

3 回答 3

7

同一行的警告是什么?

宏“DialogBoxA”的实际参数不足

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

于 2013-01-20T21:30:33.067 回答
3

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

它可能被拉进来了<iostream><vector>或者其他什么。将您的班级重命名为更原始的名称应该会有所帮助。

于 2013-01-20T21:47:36.620 回答
3

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

于 2013-01-20T21:29:49.920 回答