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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T02:16:27+00:00 2026-05-23T02:16:27+00:00

So I’ve got a Piece class supposed to represent pieces on a board, from

  • 0

So I’ve got a Piece class supposed to represent pieces on a board, from which I plan to have two other classes inheriting. I’ve gotten a lot of problems in doing so, however; here is the relevant code so far.

///
/// PIECE CLASS HERE
/// this is an abstract class from which Barrier and Pawn inherit.

class Piece
{
public:
    Piece(Space* start);
    sf::Shape m_Circle;
protected:
    int m_X;
    int m_Y;
    int m_radius;
    Space* CurrentSpace;
};

Piece::Piece(Space* start):
    m_X(start->GetX()),
    m_Y(start->GetY()),
    m_radius(14),
    CurrentSpace(start)
{}

///
/// BARRIER CLASS HERE
/// these are the white stones that block a player's path

class Barrier : public Piece
{
public:
    Barrier(Space* initial);
    void Move(Space* target, bool isCapturing);
};

Barrier::Barrier(Space* initial)
{
    Piece(initial);
    m_Circle = sf::Shape::Circle((float)m_X, (float)m_Y, (float)m_radius, sf::Color(255, 255, 255));
    Move(initial);
}

void Barrier::Move(Space* target, bool isCapturing)
{
    int xChange = abs(target->GetX() - m_X);
    int yChange = abs(target->GetY() - m_Y);
    m_Circle.Move((float)xChange, (float)yChange);
    CurrentSpace.ToggleOccupied();
    if(!isCapturing)
    {
        (*target).ToggleOccupied();
    }
    CurrentSpace = target;
}

I’m getting loads of errors I don’t understand, in particular:

no matching function for call to Piece::Piece()
declaration of 'Piece initial' shadows a parameter
no matching function for call to 'Barrier::Move(Piece&)'
request for member 'ToggleOccupied' in '((Barrier*)this)->Barrier::<anonymous>.Piece::CurrentSpace', which is of non-class type 'Space*'|

Being new to C++, I don’t understand what’s going wrong with any of this. I tried to build my code analogous to the code I found in the book I used to learn C++, but apparently I’ve overlooked some subtlety. All the functions that I try to call seem to exist in the appropriate places, and I define them with the same values as in their prototype, I think.

  • 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-23T02:16:28+00:00Added an answer on May 23, 2026 at 2:16 am

    The first error is caused by this:

    Barrier::Barrier(Space* initial)
    {
        Piece(initial);
        m_Circle = sf::Shape::Circle((float)m_X, (float)m_Y, (float)m_radius, sf::Color(255, 255, 255));
        Move(initial);
    }
    

    Needs to look like:

    Barrier::Barrier(Space* initial) : Piece(initial)
    {
        m_Circle = sf::Shape::Circle((float)m_X, (float)m_Y, (float)m_radius, sf::Color(255, 255, 255));
        Move(initial);
    }
    

    The base class’ constructor runs before your constructor (no matter what) — you need to pass arguments to it if it requires arguments in the initialization list.

    I’m not sure about the other errors because I don’t know which lines they’re occurring on.

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

Sidebar

Related Questions

I have a text area in my form which accepts all possible characters from
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a bunch of posts stored in text files formatted in yaml/textile (from
I have just tried to save a simple *.rtf file with some websites and
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I have a jquery bug and I've been looking for hours now, I can't
I've got a string that has curly quotes in it. I'd like to replace

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.