Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

C++ / CLI Copy Constructor grief

Posted on 2009-05-19
2
Medium Priority
?
1,052 Views
Last Modified: 2012-05-07
I'm converting another project from Managed Extensions for C++ (.Net 1.1) to C++/CLI (.Net 2+)

In this project we have some copy constructors.

Following http://www.functionx.com/cppcli/classes/Lesson13b.htm I have my copy constructor declared as
Shift(const Shift^ &otherShift);

The code that used to call it is:
Object ^Shift::Clone(){
      return gcnew Shift(*this);
}
But this raises the compile error C3073: 'MyNamespace::Shift' : ref class does not have a user-defined copy constructor.

I've tried (&this), (this), (%this) -- all with varying errors.

So ... how do I call this copy constructor?

Thanks!
0
Comment
Question by:Daniel Wilson
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 45

Accepted Solution

by:
AndyAinscow earned 2000 total points
ID: 24428891
Instead of
Shift(const Shift^ &otherShift);
how about
Shift(Shift^ otherShift);


and called with this
Object ^Shift::Clone(){
      return gcnew Shift(this);
}
0
 
LVL 32

Author Closing Comment

by:Daniel Wilson
ID: 31583311
That compiles ... I think you got it.

Thanks!
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
Suggested Courses

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question