473,382 Members | 1,639 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,382 software developers and data experts.

error C2248 - bug in MSVC71

I've received following code snipped from some mailing list:

1 class A
2 {
3 private:
4 A();
5 protected:
6 A(int x) {}
7 public:
8 virtual ~A() {}
9 };
10
11 class B : virtual public A
12 {
13 protected:
14 B() : A(10) {}
15 public:
16 virtual ~B() {}
17 };
18
19 class C : public B
20 {
21 public:
22 C() : A(8) {}
23 };
24
25 int main(int argc, char* argv[])
26 {
27 C c1;
28 C c2 = c1; // error here
29 return 0;
30 }

MSVC71 fails to compile it (tried with and without option /Za) :
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 13.10.3077 for
80x86
Copyright (C) Microsoft Corporation 1984-2002. All rights reserved.

T91.cpp(28) : error C2248: 'A::A' : cannot access private member
declared in class 'A'
T91.cpp(4) : see declaration of 'A::A'
T91.cpp(2) : see declaration of 'A'

the same problem is exposed by newer MSVC compiler (DDK for AMD64):
Microsoft (R) C/C++ Optimizing Compiler Version 14.00.2207 for AMD64

As far as I can understand C++ standard, there is no problem with
source. Line 28 is copy-initialization, compiler should have used
implicit non-trivial copy-constructor generated for C. Virtual base
subobject (A inside C) should have been copied by implicit-defined copy
constructor. Compiler is free to generate one for A; instead it tries to
use private default constructor for A. What's up?
B.

PS. other compilers (notably Comeau) accept this code.
Nov 16 '05 #1
1 2821
Hello Bronek,

Thanks a lot for your feedback. This issue has been entered into our bug
database and it is being investigated. It is possible that this may be
resolved in the next Visual C++ compiler service pack, but I cannot
guarantee a resolution of this issue at this time. To work around this
problem, I suggest that you can declare A(); as a public or protected
member:

class A
{
// private:
protected: //or public:
A();
......
}

Please feel free to let me know if you have any problems or concerns.

Have a nice day!

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 16 '05 #2

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

Similar topics

0
by: Tom Lee | last post by:
Hi, I'm new to .NET 2003 compiler. When I tried to compile my program using DEBUG mode, I got the following errors in the C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7 \include\xdebug...
24
by: Noah Roberts | last post by:
Item #1 in the More Exceptional C++ book uses the following construct: fstream in; .... process( in.is_open() ? in : cin,...); Where process has been shown as having various multiple...
3
by: NKH | last post by:
Hi, I am trying to recompile application that has been developed in VC++ 6.0 with VC++2005.. While compiling, I'm getting the following error.. error C2248: 'CObject::CObject' : cannot...
8
by: SilverJester | last post by:
I'm getting the following error when trying to compile my code: Not sure what it means, but it didn't start until after I added the "read_file" function (btw I know the function is mostly...
9
by: fcvcnet | last post by:
Hi, I write a class class CSegment { public: CSegment(void); public: ~CSegment(void); public: CArray< CList< CPoint, CPoint& >, CList< CPoint, CPoint& >& m_curve;
1
by: Frank | last post by:
Hello! I defined a class(CMyView1) based on CView from class wizard in VC2005, and there're following code in .h file: .... .... protected: CMyView1(); // protected constructor used...
2
by: =?Utf-8?B?S2V2aW5NdXJwaHlSSkxH?= | last post by:
I have a managed c++ class with a number of static methods, all of which are declared public. After switching from .NET 1.1 to 2.0 (Visual Studio 2003 to VS 2005), I'm now getting compiler errors...
2
by: KevinMurphyRJLG | last post by:
I have a managed C++ class with a number of static methods, all of which are declared public. After switching from .NET 1.1 to 2.0 (Visual Studio 2003 to VS 2005), I'm now getting compiler...
4
by: AngreGanon | last post by:
Hi, all~ ^^ If i use #1 OK, but use # 2 error happend what's different? #include <iostream> /* -----------# 1------------ using std::endl; using std::cout; using std::ostream;...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...

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.