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

  • Home
  • SEARCH
  • 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 8992459
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T22:57:35+00:00 2026-06-15T22:57:35+00:00

This is my first time posting on stackoverflow, so hopefully this is observing all

  • 0

This is my first time posting on stackoverflow, so hopefully this is observing all etiquette!

I am attempting to create and implement a button class in C++ using the SDL 1.x extension library for use with a personal project using a Finite State Machine. I have a base class with virtual functions, "Button", a class derived from Button, "MenuButton", and a "Title" state that attempts to create MenuButtons.

I’m using Microsoft Visual Studio 2012, and Intellisense says that my code is correct. When I attempt to compile however I receive the following two errors:

title.h(35): error C2143: syntax error : missing ‘;’ before ‘*’

title.h(35): error C4430: missing type specifier – int assumed. Note: C++ does not support default-int

I’ve spent several hours trying to figure out the problem on my own. I’ve searched google, and have been searching stackoverflow as well, but while I have seen and read numerous other posts with similar problems, none of them seemed to have the same issue I am.

Based on other similar problems posted by others, and their accepted answers, I’ve already searched for: #include loop problems, making sure class declarations have a final ;, and making sure that all #includes are included (that I know of).

The code snippets are below, I would be grateful for the wisdom and assistance if anyone would be able to tell me how to solve this.

Thank You

Button.h (the base class)

#ifndef BUTTON_H
#define BUTTON_H

#include "SDL.h"
#include "SDL_image.h"
#include "SDL_ttf.h"
#include "Functions.h"
#include "Globals.h"
#include "Constants.h"
#include <string>

using namespace std;

class Button
{
public:
    virtual void handleEvents() = 0;

    virtual void render() = 0;

    //virtual ~Button(void){};
protected:
    //Our enumerated type
    const enum mouseStates {CLIP_MOUSEOUT, CLIP_MOUSEOVER, CLIP_MOUSEDOWN, CLIP_MOUSEUP};

    //Our rect to hold the offsets and size of the button
    SDL_Rect button;

    //Array of rects to hold the dimensions of each clip from the sprit sheet
    SDL_Rect clips[4];

    //Holds the location and size of the clip to show from sprite sheet
    SDL_Rect *clip;

    //The sprite sheet surface from which we clip the button images
    SDL_Surface *buttonSpriteSheet;

    //The surface for our button text
    SDL_Surface *buttonSurfaceText;

    //The text for our button
    string buttonText;

    //The state the button will lead to when clicked
    GameStates targetState;

    //Whether we are moused over the button
    bool mouseOver;
};

#endif

MenuButton.h (Derived class)

#ifndef MENUBUTTON_H
#define MENUBUTTON_H

#include "button.h"

using namespace std;

class MenuButton :
    public Button
{
public:
    MenuButton(void);

    MenuButton(int x, int y, int w, int h, string text, GameStates state);

    void handleEvents();

    void render();

    ~MenuButton(void);
};

#endif

Title.h (The state which is creating a button and throwing the error)

#ifndef TITLE_H
#define TITLE_H

#include "GameState.h"
#include "SDL.h"
#include "SDL_image.h"
//#include "SDL_Mixer.h"
#include "Functions.h"
#include "Globals.h"
#include "Constants.h"
#include "MenuButton.h"
#include <iostream>
#include <string>

using namespace std;

class Title :
    public GameState
{
public:
    Title(void);

    //Handles intro events
    void handleEvents();

    //Handles intro logic
    void logic();

    //Handles intro rendering
    void render();

    ~Title(void);
private:
    SDL_Surface *background;
    MenuButton *testButton; //NOTE: This is the line throwing the errors
    //Mix_Music *music;
};

#endif

Thank you for the assistance!~<3

  • 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-15T22:57:36+00:00Added an answer on June 15, 2026 at 10:57 pm

    It seems the compiler doesn’t know what MenuButton is. One reason this may be the case is that MENUBUTTON_H is also defined by another header. More likely, something like Globals.h also included "title.h", i.e., you have a dependency loop in your system. If you know about classes being cyclically dependent, you are best off removing the cycles. There are many ways to do that. Even if you currently think you need the cyclic dependency, it is not good and probably not required (the book “Large Scale C++ Design” by John Lakos contains a lot of information on how to break dependency cycles).

    If you don’t know where the cycle is coming from, I recommend using the -E (or /E) flag with your compiler: This option normally yields the translation unit after it got preprocessed. It will contain indications on which file was entered in some form. How the preprocessed output looks like depends on the compiler but you’ll be able to see what the compiler gets to see and you can probably track down why MenuButton isn’t declared.

    As an easy way out you can also make sure that MenuButton is declared: To form a pointer, you don’t need its definition. It is sufficient that you have seen a definition by the time you actually access the pointer. A declaration would look something like this:

    class MenuButton;
    

    .. and can be repeated in each translation unit using MenuButton to declare pointer or reference members for MenuButton. You can even declare functions returning or passing MenuButton by value with just a declaration. Of course, when you want to actually use the type, you’d need to see its definition.

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

Sidebar

Related Questions

this is my first time posting on StackOverflow but this site is awesome. Thanks
That's my first time posting on stackoverflow. I've been finding usefull answers on this
This is my first time posting to stackoverflow, but these threads have helped me
This is the first time I am posting a question on stackoverflow, so please
This is my first time posting to this site, therefore I would appreciate all
This is my first time posting on Stackoverflow, but I've been reading through many
Hello to all this is my first time posting, thought it would be good
This is my first time posting something, first of all you got to know
This is my first time posting here. I am using GUI in java for
Good morning, all. This is my first question on stackoverflow, so hopefully this isn't

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.