Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8974765
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T18:44:34+00:00 2026-06-15T18:44:34+00:00

I am working on my little touchscreen code for an embedded microcontroller. I had

  • 0

I am working on my little touchscreen code for an embedded microcontroller. I had my code working using functions. But now I want to make it into a class. I get an error:

expression must have class type.

And I don’t know what the problem is. I googled my problem and no clear solution was found. Here’s my code:

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
        }  
    }

screen.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);
}

Can someone tell me what the problem with this code is. Its driving me totaly nuts!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T18:44:35+00:00Added an answer on June 15, 2026 at 6:44 pm

    You need to change: screen test(); to screen test;. As it is right now, you’re declaring a function named test that returns a screen, not defining an object named test of type screen.

    This is quite well known as C++’s “most vexing parse” (a good term to search for if you want more information).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a little program to make my life easier when using Microsoft
I thought people would be working on little code projects together, but I don't
I've started working a little bit with lift+scala+mongorecord but I found a small annoyance
I'm working on a little project right now in ActionScript 3. The project is
I'm working on a little project to make a 'memeplayer' in Excel with YouTube
I'm working on animating little subviews throughout my UI using a flip transition. To
I've been working a little bit on a Facebook application, but when I registered
I am working on a little game (using OS X Lion, Xcode 4, Objective-C
i am working on a little learning project and have run into an issue
I am working a little project for myself using ASP.Net MVC 2 Preview 2

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.