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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:18:46+00:00 2026-05-23T12:18:46+00:00

I am creating a pair1 class for a x and y Cartesian coordinate system.

  • 0

I am creating a pair1 class for a x and y Cartesian coordinate system. x and y are doubles. I need to have 3 constructors.

  1. No arguments, defaults x and y to zero.
  2. One arguement assigns x and defaults y to zero.
  3. One arugeument defaults x to zero and assigns y. I’m not sure if I am setting up the class right. I get the follwing error: pair1::pair1(double) and pair1::pair1(double) cannot be overloaded.

My class:

class pair1
{
private:
    double x;
    double y;

public:
    pair1(){ x = 0.0, y = 0.0; }    
    pair1( double a ){ x = a; y =0.0; }
    pair1(double b){ x = 0.0;  y = b; }
};
  • 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-23T12:18:47+00:00Added an answer on May 23, 2026 at 12:18 pm

    1) no arguments, defaults x and y to
    zero.

    That’s easy

    2) one arguement assigns x and
    defaults y to zero.

    3) one arugeument
    defaults x to zero and assigns y.

    That’s a problem. How do you know, when you only have one parameter, which of the two is meant to be called? That’s why you get a compilation error.

    Instead – use the default constructor (the one with no parameters), full constructor (the one with both), if needed, and SetX() and SetY() to set the X and Y separately, and make distinction by the name of the function.

    class pair1
    {
        private:
        double x;
        double y;
    
        public:
        pair1( double a=0.0, double b=0.0 ){ x = a; y =b; };
                         // default value 0.0 allows to only
                         // set x, and leave y to be the default,
                         // or leave them both default.
        void SetX(double a) { x=a;};
        void SetY(double b) { y=b;};
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a WPF ListView control for which I am dynamically creating columns. One
When creating a web application, and lets say you have a User object denoting
Currently I have the function CreateLog() for creating a a log4net Log with name
I am creating an iPhone app which I would like to have a similar
Example I have a repository class (DAL): public class MyRepository : IMyRepository { public
Imagine I have a C# app sitting on a server somewhere that is creating
In jQuery, I'm creating several div elements within a class: function class([..]) { this.par1
While creating a simple client for a REST service which I have stubbed out,
I've been thinking about creating a class in C++ on graph theory. The idea
Here's the situation: I have an abstract class with a constructor that takes a

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.