?
Solved

C++ / CLI Copy Constructor grief

Posted on 2009-05-19
2
Medium Priority
?
1,037 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 44

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

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
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

770 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