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 583953
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T14:50:51+00:00 2026-05-13T14:50:51+00:00

I have made a class and it compiles with no syntax errors, but I

  • 0

I have made a class and it compiles with no syntax errors, but I get 6 unresolved external symbols?

THE CLASS:

struct CELL {
private:
    static bool haslife;
static int x;
static int y;
public:

    static bool has_life()
    {
        return haslife;
    }

    static void set_coords(int xcoord, int ycoord)
    {
        x = xcoord;
        y = ycoord;
    }
    static void get_coords(int &xcoord, int &ycoord)
    {
        xcoord = x;
        ycoord = y;
    }


};


class cell_grid {
private:
static int cell_size;
static int cell_count_x;
static int cell_count_y;
CELL **cell;
public:
    cell_grid();
    cell_grid(unsigned int width,unsigned int height, unsigned int cellsize)
    {

        //set size based on cellsize

        this->cell_size = cellsize;
        this->cell_count_x = floor((double)width / this->cell_size);
        this->cell_count_y = floor((double)height / this->cell_size);


        this->cell = new CELL*[this->cell_count_y];

        for(int i = 0; i < this->cell_count_y; i++)
        {
            cell[i] = new CELL[this->cell_count_x];
        }

        for(int y = 0; y < this->cell_count_y; ++y)
        {
            for(int x = 0; x < this->cell_count_x; ++x)
            {
                int cur_x = x * this->cell_size;
                int cur_y = y * this->cell_size;
                this->cell[x][y].set_coords(cur_x,cur_y);
            }
        }

    } //end of constructor

    static int get_cell_size()
    {
        return cell_size;
    }
static void render(BITMAP *buff)
{
    circlefill(buff,70,70,60,makecol(27,37,0));

}


};

MAIN

int main()
{
    start_allegro();
    cell_grid *grid = new cell_grid(scr_w,scr_h,10);
    grid->render(buffer);


        //Main Loop
    while (!done && !key[KEY_ESC]) //until 'X' pressed or ESC
{
//***** Start Main Code Here *****
    while (speed_counter > 0)
    {



                 //render the buffer to the screen

            blit(
            buffer,
            screen,
            0,0,0,0,
            scr_w,
            scr_h);

            clear_bitmap(buffer);

        speed_counter --;
    }
//***** End Main Code Here *****
rest(1); //Normalize cpu usage
}
    return 0;
}
END_OF_MAIN()

Thanks

  • 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-05-13T14:50:51+00:00Added an answer on May 13, 2026 at 2:50 pm

    Don’t define all of the class variables as static.
    When you define a data member as static it means there is only one single instance of it. This doesn’t seem to be what you want to do here.
    Instead of

    private:
        static bool haslife;
        static int x;
        static int y;
    

    write:

    private:
        bool haslife;
        int x;
        int y;
    

    Further more, when you define a static member, you need to define it again in the CPP file and initialize it with a value. It doesn’t look like you’re doing that and that’s why you’re getting the linker errors.

    Also, next time you post something, make sure you actually ask a question rather than just simply stating facts.

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

Sidebar

Related Questions

I have made a generic Observer interface and an Observable class, but can't compile
I have made the static class below so any class may access any of
I have made an class which conforms to the NSCoding protocol and does all
I have made a Java class where I have defined a constructor and some
I made a music class that will play a song. I have made onResume
I have made my own exception class which derives from runtime_error and is getting
I have made a front end for a program which test java (foo.class) binary
This is a C++ class that I have made with n number of pointers.
I am learning C++ and I have a question. I made a class in
I have a custom-made view that extends the View class. I would like 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.