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

when i run this code : CONADefinitions.CONAPI_FOLDER_INFO2 FolderInfo; int iResult = 0; IntPtr Buffer
I have this block of code: int myFunc( std::string &value ) { char buffer[fileSize];
I have this function: void receive_message(int sock, char buffer[]) { int test = recv(sock,
I'm using System.IO.Stream.Read(byte[] buffer, int offset, int count) . Is there an alternative to
int x = n / 3; // <-- make this faster // for instance
The code states: void (* log_msg)(char *msg) =printf; void change_and_log(int *buffer, int offset, int
This is possibly a candidate for a one-line answer. I would like know it
#include <iostream> using namespace std; int main() { char buffer[8]; int field=534; memcpy(buffer,&field,sizeof(field)); cout<<buffer<<endl;
int BUFFER_SIZE = 4096; byte[] buffer = new byte[BUFFER_SIZE]; InputStream input = new GZIPInputStream(new
I've been trying forever to get this working. The program is supposed to take

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.