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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T09:54:33+00:00 2026-06-10T09:54:33+00:00

Here is my code: //————————————————————————— #pragma hdrstop #include <tchar.h> #include <string> #include <iostream> #include

  • 0

Here is my code:

//---------------------------------------------------------------------------

#pragma hdrstop

#include <tchar.h>
#include <string>
#include <iostream>
#include <sstream>
#include <conio.h>

using namespace std;

//---------------------------------------------------------------------------

class Wheel
{
public:
        Wheel()
    {
        pressure = 32;
        ptrSize = new int(30);
    }
    Wheel(int s, int p)
    {
        ptrSize = new int(s);
        pressure = p;
    }
    ~Wheel()
    {
        delete ptrSize;
    }
    void pump(int amount)
    {
       pressure += amount;
    }

private:
    int *ptrSize;
    int pressure;
};

class RacingCar
{
public:
    RacingCar()
    {
        speed = 0;
        Wheel carWheels = new Wheel[3];
    }
    RacingCar(int s)
    {
        speed = s;
    }
    void Accelerate()
    {
        speed = speed + 10;
    }

private:
    int speed;
};

I using this code to create a RacingCar object:

RacingCar test();

Yet am getting the following error:

[BCC32 Error] Question 4.cpp(48): E2285 Could not find a match for ‘Wheel::Wheel(const Wheel&)’

At line:

Wheel carWheels = new Wheel[3];

I am wanting to create an array of 4 wheels as an array of objects on the heap.

What am I doing wrong?

UPDATE

I am wanting to use a copy constructor for class RacingCar that will create a deep copies of RacingCar objects and then write code to prove that the copy of the RacingCar object is a deep copy.

Can I please have some help to do this?

Here is my code:

class RacingCar
{
public:
    RacingCar()
    {
        speed = 0;
        Wheel* carWheels = new Wheel[3];
    }
    RacingCar(int s)
    {
        speed = s;
    }
    RacingCar(const RacingCar &oldObject)
    {
        //I am not sure what to place here.
        Wheel* carWheels = new Wheel[3];

    }
    void Accelerate()
    {
        speed = speed + 10;
    }

private:
    int speed;
};

* 2nd UPDATE

Here is my current code:

class Wheel
{
public:
    Wheel() : pressure(32)
    {
        ptrSize = new int(30);
    }
    Wheel(int s, int p) : pressure(p)
    {
        ptrSize = new int(s);
    }
    ~Wheel()
    {
        delete ptrSize;
    }
    void pump(int amount)
    {
        pressure += amount;
    }
    int getSize()
    {
        return *ptrSize;
    }
    int getPressure()
    {
        return pressure;
    }
private:
    int *ptrSize;
    int pressure;
};

class RacingCar
{
public:
    RacingCar()
    {
        speed = 0;
        *carWheels = new Wheel[4];
    }
    RacingCar(int s)
    {
        speed = s;
    }
    RacingCar(const RacingCar &oldObject)
    {
        for ( int i = 0; i < sizeof(carWheels)/sizeof(carWheels[0]); ++i)
        {
            Wheel oldObjectWheel = oldObject.getWheel(i);
            carWheels[i]=new Wheel(oldObjectWheel.getSize(),oldObjectWheel.getPressure());
        }

    }
    void Accelerate()
    {
        speed = speed + 10;
    }
    Wheel getWheel(int id)
    {
        return *carWheels[id];
    }
private:
    int speed;
    Wheel *carWheels[4];
};

The copy constructor is not working correctly. I am getting an error at:

Wheel oldObjectWheel = oldObject.getWheel(i);

What am I doing wrong?

  • 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-10T09:54:34+00:00Added an answer on June 10, 2026 at 9:54 am

    I wrote an example of deep-copy, wish this helps.

    //---------------------------------------------------------------------------
    
    #include <iostream>
    
    using namespace std;
    
    //---------------------------------------------------------------------------
    
    class Demo
    {
    public:
        // Constructor
        Demo()
        {
            ptrNeedsDeepCopy = new int(10);
        }
    
        // Copy constructor
        Demo(const Demo& rhs)
        {
            // You need to allocate new memory to make sure the two
            // objects are not pointing to the same memeory.
            ptrNeedsDeepCopy = new int(*(rhs.ptrNeedsDeepCopy));
        }
    
        // Copy assign operator
        Demo& operator=(const Demo& rhs)
        {
            // Do things same in the copy constructor
            // AND!!! you have to check that the object is not
            // assigning it to itself.
            if(this != &rhs)
            {
                ptrNeedsDeepCopy = new int(*(rhs.ptrNeedsDeepCopy));  
            }
            return *this;
        }
    
        // Destructor
        ~Demo()
        {
            delete ptrNeedsDeepCopy;
        }
    
        void SomeMemberFunctions()
        {
            // What ever.
        }
    
        int GetPtrValue()
        {
            if(ptrNeedsDeepCopy)
            {
                return *ptrNeedsDeepCopy;
            }
        }
    
        void SetPtrValue(int val)
        {
            if(ptrNeedsDeepCopy)
            {
                *ptrNeedsDeepCopy = val;  
            }
        }
    
    private:
        int *ptrNeedsDeepCopy;
    
    };
    
    int main()
    {
        Demo a;
        Demo b = a;
    
        cout << "a's initial value: " << a.GetPtrValue() << endl;
        cout << "b's initial value: " << b.GetPtrValue() << endl;
    
    
        a.SetPtrValue(7);
    
        cout << endl;
    
        cout << "a's changed value: " << a.GetPtrValue() << endl;
        cout << "b's changed value: " << b.GetPtrValue() << endl;
    
        return 0;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

here is code for regular expression matching #include<iostream> #include<stdio.h> #include<string.h> using namespace std; int
Here a code to demonstrate an annoying problem: class A { public: A(): m_b(1),
Here is code example class A{ int i; public: A(int i) : i(i) {}
I'm trying to match this block here /code\ int foo(string $bar, int $bleh); Simple
Here my code <a href=http://linkurl class=link title=sometitle> text link <span class=hidden-tooltip-data style=display: none;> <a
Here is code: procedure DisableContrlOL(const cArray : array of string; ReEnable : boolean =
The script is on jsfiddle here : CODE What it does at the moment
Ok the error is showing up somewhere in this here code if($error==false) { $query
Here is code my jqgrid editing through form. $(#DataEnergy).jqGrid('navGrid', '#pagergrid', {}, //options {editdata: {
Here my code, I need to insert into mysql database I have mysql,php,android 1)

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.