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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:32:08+00:00 2026-05-26T14:32:08+00:00

i use smart pointers in the following way: typedef std::tr1::shared_ptr<RealAlgebraicNumber> RealAlgebraicNumberPtr; I’m using the

  • 0

i use smart pointers in the following way:

typedef std::tr1::shared_ptr<RealAlgebraicNumber> RealAlgebraicNumberPtr;

I’m using the smart pointer things because RealAlgebraicNumber is an “abstract” superclass. It works fine and now i want a class to encapsulate a vector. It looks like this:

class RealAlgebraicPoint
{
public:
    RealAlgebraicPoint (vector<RealAlgebraicNumberPtr>& v);
    RealAlgebraicPoint (RealAlgebraicPoint& R);
    RealAlgebraicPoint conjoin (const RealAlgebraicNumber& N);
private:
    vector<RealAlgebraicNumberPtr> mNumbers;
    unsigned int mSize;
};

And the implementation is like this:

RealAlgebraicPoint::RealAlgebraicPoint(vector<RealAlgebraicNumberPtr>& v)
    : mNumbers(v), mSize(mNumbers.size()) {}
RealAlgebraicPoint::RealAlgebraicPoint(RealAlgebraicPoint& R)
    : mNumbers(R.mNumbers), mSize(mNumbers.size()) {}
RealAlgebraicPoint RealAlgebraicPoint::conjoin (const RealAlgebraicNumber& N)
{
    vector<RealAlgebraicNumberPtr> v;
    // do something fancy with v!
    return RealAlgebraicPoint(v); // this is line 58
}

Unfortunatly I get ugly errors like this:

RealAlgebraicPoint.cpp: In member function 'GiNaC::RealAlgebraicPoint GiNaC::RealAlgebraicPoint::conjoin(const GiNaC::RealAlgebraicNumber&)':
RealAlgebraicPoint.cpp:58:32: error: no matching function for call to 'GiNaC::RealAlgebraicPoint::RealAlgebraicPoint(GiNaC::RealAlgebraicPoint)'
RealAlgebraicPoint.cpp:46:1: note: candidates are: GiNaC::RealAlgebraicPoint::RealAlgebraicPoint(GiNaC::RealAlgebraicPoint&)
RealAlgebraicPoint.cpp:42:1: note: GiNaC::RealAlgebraicPoint::RealAlgebraicPoint(std::vector<std::tr1::shared_ptr<GiNaC::RealAlgebraicNumber> >&)
RealAlgebraicPoint.cpp:38:1: note: GiNaC::RealAlgebraicPoint::RealAlgebraicPoint(unsigned int&)

Any ideas? I’m really consfused why he trys to call RealAlgebraicPoint(GiNaC::RealAlgebraicPoint) as I am only calling RealAlgebraicPoint(std::vector<std::tr1::shared_ptr<GiNaC::RealAlgebraicNumber> >&).

Thank you!

Joachim

  • 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-26T14:32:09+00:00Added an answer on May 26, 2026 at 2:32 pm

    The copy constructor should take a reference to const.

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

Sidebar

Related Questions

I have to use a smart pointer and I found shared_ptr from boost looks
I've been trying to use smart pointers to upgrade an existing app, and I'm
What is a smart pointer and when should I use one?
I use the following smart-tab defun in my .emacs for either completion on a
I'll start out by saying, use smart pointers and you'll never have to worry
We use Microsoft Smart client, Enterprise Library, Composite Application Block and Infragistics and some
Thinking of a way how to best approach the following design (pseudo C++ code):
Im playing with my smart pointer class and I want to implement ++ and
I'm quite new to smart pointers and was trying to refactor some existing code
Currently ive got some reference counted classes using the following: class RefCounted { public:

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.