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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T02:18:34+00:00 2026-05-15T02:18:34+00:00

trying to work out how to use constructors with an inherited class. I know

  • 0

trying to work out how to use constructors with an inherited class. I know this is very much wrong, I’ve been writing C++ for about three days now, but here’s my code anyway:

clientData.h, two classes, ClientData extends Entity :

#pragma once

class Entity
{
public:
 int x, y, width, height, leftX, rightX, topY, bottomY;

 Entity(int x, int y, int width, int height);
 ~Entity();
};

class ClientData : public Entity
{
public:
 ClientData();
 ~ClientData();
};

and clientData.cpp, which contains the functions:

#include <iostream>
#include "clientData.h"
using namespace std;

Entity::Entity(int x, int y, int width, int height)
{
 this->x = x;
 this->y = y;
 this->width = width;
 this->height = height;

 this->leftX = x - (width/2);
 this->rightX = x + (width/2);
   this->topY = y - (height/2);
 this->bottomY = y + (height/2);
}

Entity::~Entity()
{
 cout << "Destructing.\n";
}

ClientData::ClientData()
{
 cout << "Client constructed.";
}

ClientData::~ClientData()
{
    cout << "Destructing.\n";
}

and finally, I’m creating a new ClientData with:

ClientData * Data = new ClientData(32,32,32,16);

Now, I’m not surprised my compiler shouts errors at me, so how do I pass the arguments to the right classes?

The first error (from MVC2008) is
error C2661: ‘ClientData::ClientData’ : no overloaded function takes 4 arguments

and the second, which pops up whatever changes I seem to make is
error C2512: ‘Entity’ : no appropriate default constructor available
Thanks.

  • 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-15T02:18:35+00:00Added an answer on May 15, 2026 at 2:18 am

    Currently the constructor for the Client data class wont work. You will need to make a constructor for Client data like:

    ClientData(int x, int y, int width, int height): Entity(x, y, width, height)
    

    if you want to call

    new ClientData(32,32,32,16);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been trying to use a formula that is used to work out
I've been reading about the @font-face rule and trying to work out if it's
I found this in an error log and am trying to work out how
I'm trying to work this out. In my project, i have a file called
I am trying to work out the best database model for the current setup:
I am trying to work out how to get the value of table cell
I'm trying to work out a way of passing the web current http context
I am trying to work out a code sample to demonstrate the debugging functionality
I am trying to work out the format of a password file which is
I'm still working on groking the F# thing - trying to work out how

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.