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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:58:50+00:00 2026-05-28T02:58:50+00:00

I just finished creating a Point class and was working on a Line class

  • 0

I just finished creating a “Point” class and was working on a “Line” class that has two Point objects (Point startpoint and Point endpoint) as data members. I created a constructor in my Line class that accepts two Point objects as arguments and had originally created it as follows:

Line(const Point& p1, const Point& p2)
{
    startpoint = p1;
    endpoint = p2;
}

Everything was fine, but then I decided I would use a member initialization list instead of assigning the members to p1 and p2 in the body, just because… But when I changed it to:

Line(const Point& p1, const Point& p2): startpoint(p1), endpoint(p2)
{
}

I get an error saying “no instance of constructor “Point::Point” matches the argument list” and didn’t understand what this meant exactly.

Why doesn’t the member initialization list work here?

Thanks.

edit: Sorry, I didn’t know if the details of my point class was relevant or not:

// Point.h

class Point
{
private:
    double x;
    double y;

public:
    Point();
    Point(Point& p);
    Point(double x1, double y1);
    ~Point();

    double X() const;
    double Y() const;

    void X(double newx);
    void Y(double newy);
    };

// Point.cpp

#include "Point.h"

Point::Point(): x(0), y(0)
{
}

Point::Point(Point& p)
{
    x = p.x;
    y = p.y;
}

Point::Point(double x1, double y1): x(x1), y(y1)
{
}

Point::~Point()
{
}

double Point::X() const
{
    return x;
}

double Point::Y() const
{
    return y;
}

void Point::X(double newx)
{
    x = newx;
}

void Point::Y(double newy)
{
    y = newy;
}
  • 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-28T02:58:51+00:00Added an answer on May 28, 2026 at 2:58 am

    The member initialization depends on Point having a public copy constructor, since you explicitly calling Point::Point(const Point&).

    If that doesn’t exist or is not accessible, you can’t call it. If you can’t call it, it isn’t because the initialization list doesn’t work, though.

    Presumably Point has an accessible assignment operator, if the first version works.


    Just to confirm, now you’ve pasted the source for Point, the copy constructor should look like:

    Point::Point(const Point &other) : x(other.x), y(other.y) {}
    

    (you might as well get comfortable using the initializer list).
    The key change is the argument must be a const reference: this prohibits accidentally damaging the source object when copying.

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

Sidebar

Related Questions

I'm creating an instance of a class called S3ObjectController (S3OC) that has one method
I have just finished creating my signup form and now ready to insert data
I just finished creating my first major application in C#/Silverlight. In the end the
Just finished reading this blog post: http://www.skorks.com/2010/03/an-interview-question-that-prints-out-its-own-source-code-in-ruby/ In it, the author argues the case
I just finished creating T4 templates to auto-generate property implementations for my ViewModel classes
I just finished creating a new user for my database in SQL Server. I
I'm in part four of the MvcMusicStore tutorial . I just finished creating my
I'm creating a new rails app for my business, and I just finished a
I'm working with .Net using VB and have just finished a website project and
I creating a C# application that has to create a word document. I'm using

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.