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

The Archive Base Latest Questions

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

this may be a very basic c++ question but I am a bit rusty.

  • 0

this may be a very basic c++ question but I am a bit rusty. I am trying to set up a maze type data structure with points. Here is my code.

class Point{

    public :

    int xCoord;
    int yCoord;
    bool visited;

    //constructors
    Point(){}
    Point(int x, int y){
        xCoord = x;
        yCoord = y;
        visited = false;
    }
    int makeVisited(){
        visited = true;
    }

    int makeUnvisited(){
        visited = false;
    }
};



class Maze{

    public :

    int width;
    int height;
    Point ** grid; 

    //constructors
    Maze(){}
    Maze(int X, int Y){
        width = X;
        height = Y;
        grid = new Point*[width];
        for(int i = 0; i < width; i++){
            grid[i] = new Point[height];
            for(int j = 0; j < height; j++){
                grid[i][j] = new Point(i, j);
            }
        }
    }
}; //end of Maze class

When I try to asign grid[i][j] a new point instance, I get an error saying

“error no operator “=” matches these operands”

Can someone tell me what I did wrong with the initialization of the point object?

  • 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-13T22:21:17+00:00Added an answer on June 13, 2026 at 10:21 pm

    Since grid is declared as a Point**, then grid[i][j] is of type Point. So you can’t assign a new Point to this.


    One thing you can do is to define a setter member function, like:

    void Point::set(int x, int y) {
      xCoord = x;
      yCoord = y;
    }
    

    And then in your loop you can use:

    grid[i][j].set(i, j);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I understand this question may sound very basic but I have been trying to
This may be a very basic question but somehow it got me tricked... when
This may be a very basic question. But it is not very clear to
This may be a very basic question, but is it possible to post a
This may be a very basic question. But I am finding it confusing with
I know this may be a very basic question, sorry if it is but
This may seem like a very basic question, well, it is, but I am
this may be a very basic question but I haven't used Linq much so
This may be a very basic question but it is one I am seeking
This may be a basic question but I'm not very proficient in SQL Server.

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.