C++ &引用;表达式必须具有“类类型”;错误

C++ &引用;表达式必须具有“类类型”;错误,c++,class,microcontroller,C++,Class,Microcontroller,我正在为嵌入式微控制器编写我的小触摸屏代码。我让我的代码使用函数工作。但现在我想把它变成一门课。我得到一个错误: 表达式必须具有类类型 我不知道问题出在哪里。我用谷歌搜索了我的问题,没有找到明确的解决办法。这是我的密码: main.cpp #include "screen.h" #include "mbed.h" #include "stdio.h" screen test(); int main(void) { while (1) {

我正在为嵌入式微控制器编写我的小触摸屏代码。我让我的代码使用函数工作。但现在我想把它变成一门课。我得到一个错误:

表达式必须具有类类型

我不知道问题出在哪里。我用谷歌搜索了我的问题,没有找到明确的解决办法。这是我的密码:

main.cpp

#include "screen.h"
#include "mbed.h"
#include "stdio.h"

screen test();

    int main(void)
    {

        while (1)
        {
        test.button(50,70,100,50,"button1"); // line where the compiler sees an error
        }  
    }
屏幕.h

class screen{

public:

        screen();

        void init();
        void button(int, int, int, int, string);

private:
        int runningstatus; // 0 = stopped // 1 = failure // 2 = running
        point p;


};
screen.cpp

#include "screen.h"

touch_tft TFT(p20,p18,p17,p16,p5, p6, p7, p8, p15,"TFT"); // x+,x-,y+,y-,mosi, miso, sclk, cs, reset


screen::screen(){


}

void screen::init()
{
        TFT.claim(stdout);          // send stdout to the TFT display 
    TFT.background(Black);    // set background to black
    TFT.foreground(White);    // set chars to white
    TFT.cls();                // clear the screen
    TFT.set_orientation(3);
    TFT.set_font((unsigned char*) Arial24x23);
        TFT.locate(60, 100);
}

void screen::button(int x0, int y0, int length, int height, string caption)
{
        TFT.rect(x0     ,y0     ,x0+length      ,y0+height,     LightGrey);
        TFT.rect(x0-1   ,y0-1   ,x0+length+1    ,y0+height+1, LightGrey);
        TFT.fillrect(x0-2,y0-2 ,x0+length-1 ,y0+height-1, Navy);

        TFT.locate(x0+10, y0+10);

        TFT.background(Navy);   
        TFT.printf("%s", caption);
}

有人能告诉我这个代码有什么问题吗。这简直把我逼疯了

您需要更改:
屏幕测试()至<代码>屏幕测试。现在,您正在声明一个名为
test
的函数,该函数返回一个
screen
,而不是定义类型为
screen
的名为
test
的对象


这就是众所周知的C++的“最烦人的解析”(如果您想了解更多信息,可以搜索这个好词)。

当然!你的权利!妈的,我太傻了,我自己都没发现。。这里是全掌!再次感谢!哈哈,你应该回答我的问题(而不是评论),这样其他有类似问题的人也可以找到答案(如果我是为自己说话的话,我通常只在这个网站上读答案。不是评论。@JerryCoffin:你应该把它作为一个答案发布。