Possible copy constructor bug

I

Ioannis Vranos

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?
 
P

Puchi

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
 
I

Ioannis Vranos

Puchi said:
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.
 
I

Ioannis Vranos

Ioannis said:
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".
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top