473,406 Members | 2,847 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Possible copy constructor bug

Unless I missing something, I think this is a bug.
ref class A
{
};
ref class B
{
public:
B(A) { }
B() {}
};
int main()
{
A a;

B b(a);
}
C:\c>cl /clr:safe temp.cpp
Microsoft (R) C/C++ Optimizing Compiler Version 14.00.41013
for Microsoft (R) .NET Framework version 2.00.41013.0
Copyright (C) Microsoft Corporation. All rights reserved.

temp.cpp
temp.cpp(18) : error C2664: 'B::B(A)' : cannot convert parameter 1 from
'A' to '
A'
Cannot copy construct class 'A' due to ambiguous copy
constructors or no
available copy constructor

C:\c>

Am I making some mistake?


--
Ioannis Vranos
Nov 17 '05 #1
3 1031
Try the following code, not the missing % from your example.
using namespace System;
ref class A
{
};
ref class B
{
public:
B(A%) { }
B() {}
};
int main()
{
A a;
B b(a);
}

Thanks,
Kapil
"Ioannis Vranos" <iv*@guesswh.at.grad.com> wrote in message
news:e9**************@tk2msftngp13.phx.gbl...
Unless I missing something, I think this is a bug.
ref class A
{
};
ref class B
{
public:
B(A) { }
B() {}
};
int main()
{
A a;

B b(a);
}
C:\c>cl /clr:safe temp.cpp
Microsoft (R) C/C++ Optimizing Compiler Version 14.00.41013
for Microsoft (R) .NET Framework version 2.00.41013.0
Copyright (C) Microsoft Corporation. All rights reserved.

temp.cpp
temp.cpp(18) : error C2664: 'B::B(A)' : cannot convert parameter 1 from
'A' to '
A'
Cannot copy construct class 'A' due to ambiguous copy
constructors or no
available copy constructor

C:\c>

Am I making some mistake?


--
Ioannis Vranos

Nov 17 '05 #2
Puchi wrote:
Try the following code, not the missing % from your example.

using namespace System;
ref class A
{
};
ref class B
{
public:
B(A%) { }
B() {}
};
int main()
{
A a;
B b(a);
}

I know that % was missing, however % is not mandatory.

--
Ioannis Vranos
Nov 17 '05 #3
Ioannis Vranos wrote:
ref class A
{
};
ref class B
{
public:
B(A) { }
B() {}
};
int main()
{
A a;

B b(a);
}
C:\c>cl /clr:safe temp.cpp
Microsoft (R) C/C++ Optimizing Compiler Version 14.00.41013
for Microsoft (R) .NET Framework version 2.00.41013.0
Copyright (C) Microsoft Corporation. All rights reserved.

temp.cpp
temp.cpp(18) : error C2664: 'B::B(A)' : cannot convert parameter 1 from
'A' to '
A'
Cannot copy construct class 'A' due to ambiguous copy
constructors or no
available copy constructor

C:\c>

I reported it as a bug under the title:
"Copy constructor bug".

--
Ioannis Vranos
Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: CoolPint | last post by:
It seems to me that I cannot assign objects of a class which has a constant data member since the data member cannot be changed once the constructor calls are completed. Is this the way it is meant...
42
by: Edward Diener | last post by:
Coming from the C++ world I can not understand the reason why copy constructors are not used in the .NET framework. A copy constructor creates an object from a copy of another object of the same...
15
by: A | last post by:
Hi, A default copy constructor is created for you when you don't specify one yourself. In such case, the default copy constructor will simply do a bitwise copy for primitives (including...
8
by: trying_to_learn | last post by:
Why do we need to explicitly call the copy constructor and the operator = , for base class and member objects in composition? ....book says "You must explicitly call the GameBoard copy-constructor...
8
by: Jesper | last post by:
Hi, Does the concept "copy constructor" from c++ excist in c#. What is the syntax. best regards Jesper.
10
by: utab | last post by:
Dear all, So passing and returning a class object is the time when to include the definition of the copy constructor into the class definition. But if we don't call by value or return by value, ...
8
by: shuisheng | last post by:
Dear All, I am wondering how the default copy constructor of a derived class looks like. Does it look like class B : public A { B(const B& right) : A(right) {}
22
by: clicwar | last post by:
A simple program with operator overloading and copy constructor: #include <iostream> #include <string> using namespace std; class Vector { private: float x,y; public: Vector(float u, float...
4
by: Rahul | last post by:
Hi Everyone, It is well known that the input parameter which is passed to the copy constructor is passed as reference and not as as object. Because passing an object is as good as making another...
9
by: puzzlecracker | last post by:
From my understanding, if you declare any sort of constructors, (excluding copy ctor), the default will not be included by default. Is this correct? class Foo{ public: Foo(int); // no...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.