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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T21:48:30+00:00 2026-05-21T21:48:30+00:00

int buffer[gSizeOfGrid][gSizeOfGrid]; CList *currentCList; Grid *currentGrid; //this line get the error int aroundinfo[4]; //other

  • 0
int buffer[gSizeOfGrid][gSizeOfGrid];
CList *currentCList;
Grid *currentGrid; //this line get the error
int aroundinfo[4];
//other functions are not revelant maybe? They don't
//use currentGrid.

the class Grid has the header:

class Grid
{
public:
    Grid();
    //create default cList object for the grid .
    Grid(CList*);
    //create cList and bind existing clist object.
    bool rebind(CList*);
    //rebind cList.
    ~Grid();
    void init(int ants,int bugs);
    //init a grid with ants and bugs according to parameter.
    void GetSnapshot();
    //synchronize grid buffer with clist.
    void Step();
    //make the world go on!
    bool spawn(Creature&,Position);
    //create a creature on the grid.
    //if success, return true.
    //if there are already another creature return false.
    void move(Position,int);
    void eat(Position,int);
    void breed(Position,int);
    void destroy(Position);
private:
    CList* theList;
};

the Clist Class looks the same but is Okay in declaration:

using namespace std;
class CList
{
public:
    CList();
    int CreateObject(Creature&,Position);
    Creature& GetObject(int);
    bool RemoveObject(Position);
    bool RemoveObject(int);
    int getType(Position);
    void cleanup();
    vector<Creature*> list;
    int size();
};

Why the Grid* declaration goes wrong but CList* is OK? Thank you!

  • 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-21T21:48:31+00:00Added an answer on May 21, 2026 at 9:48 pm

    This is because class Grid is not visible to the pointer currentGrid. Just do following and it should work;

    class Grid;
    Grid *currentGrid;
    

    I assume that you may not want to #include the Grid header before this declaration as, Grid itself is using CList. The best way should be to include all the headers before this declarations.

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

Sidebar

Related Questions

I'm getting TypeError: coercing to Unicode: need string or buffer, int found This is
I've used: sprintf(hex, %02x, (unsigned int) buffer[0] & 0xff); to get hexadecimal representation of
I use this function to get a line of text from a rich edit
I have this buffer given: unsigned char *buffer; int buffer_length; This is how I
scala> import scala.collection.mutable.Buffer import scala.collection.mutable.Buffer scala> val b = Buffer(1, 2, 3) b: scala.collection.mutable.Buffer[Int]
I got the following code: char buffer[2047]; int charsRead; do { if(fscanf(file, %2047[^\n]%n%*c, buffer,
When reading normally from an SslStream using the Read(byte[] buffer, int offset, int count)
I use fread to read into a char buffer. char buffer[50]; int nbytes =
void* ptr1 = NULL; void* ptr2 = ptr1; unsigned int *buf = data;//some buffer
I have the following code: #include <string.h> int main(void) { char *buffer = NULL,

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.