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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:32:19+00:00 2026-05-27T10:32:19+00:00

I am getting the following errors when making Arrays of two obecjts.. Edge and

  • 0

I am getting the following errors when making Arrays of two obecjts.. Edge and Box.

error: conversion from 'const Edge*' to non-scalar type 'Edge' requested.

I am hoping to return an array of Edges.

On this header file:

class Box
{
private:
    bool playerOwned; 
    bool computerOwned;
    Edge boxEdges[4];
    int openEdges;
    bool full;

public:
    Box();
    Box(int x, int y);
    void setEdges(Edge boxTop, Edge boxBottom, Edge boxLeft, Edge boxRight);
    void addEdgeToBox(Edge edge); //add edge to edgeArray.
    void setPlayerOwned(bool point);
    Edge getBoxEdges() const {return boxEdges;}                ****//Error****
    bool getPlayerOwned() const {return playerOwned;}
    void setComputerOwned(bool point);
    bool getComputerOwned()const {return computerOwned;}
    int getOpenEdges() const {return openEdges;}
    bool isFull()const {return full;}

};
std::ostream& operator<< (std::ostream& out, Box box);

I get the same error except replace ‘Edge’ with ‘Box’ on the following line in a non-header file attempting to create a Box.

  Box box = new Box(x+i,y);
  • 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-27T10:32:20+00:00Added an answer on May 27, 2026 at 10:32 am
    Box box = new Box(x+i,y);  //error
    

    One error is right here. You should write this as:

    Box *box = new Box(x+i,y); //ok
    

    It is because when you use new, you’re allocating memory, and only a pointer can hold a memory, so box has to be pointer type.

    Similarly,

    Edge getBoxEdges() const {return boxEdges;}  //error
    

    should be written as:

    const Edge* getBoxEdges() const {return boxEdges;}  //ok
    

    It is because boxEdges is an array, which can decay into pointer type to its first element, and since it is const member function, boxEdges will decay into const Edge*.


    By the way, instead of pointer in the first case, you use automatic object as:

    Box box(x+i, y); //ok
    

    I would suggest you to make the second parameter of operator<< a const reference:

    //std::ostream& operator<< (std::ostream& out, Box box); //don't use this
    std::ostream& operator<< (std::ostream& out, Box const & box); //use this
    

    This avoids unnecessary copy!

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

Sidebar

Related Questions

I am getting following errors on my console repeatedly log4j:ERROR Attempted to append to
Upon using PKEY_Device_FriendlyName, I'm getting the following errors: Error 1 error LNK2001: unresolved external
I'm getting the following two errors when loading my page: Notice: Undefined variable: realtor
Hello friends I am getting the following error while making the foreign key 'tbl_course'
I am making a java game and I am getting the following error: actionPerformedException
I am writing an sql query using pivot and I am getting following errors:
When am trying to set default date and default sysdate am getting following errors:
While validating my CSS on http://jigsaw.w3.org/css-validator/ I am getting following errors: 1.Property zoom doesn't
I am getting the following errors: PHP Warning: Module 'ldap' already loaded in Unknown
I am getting the following errors when i am trying to index the SVN

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.