473,543 Members | 1,996 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Error about inaccessable class

In the code below gcc says

test.cpp: In constructor `SingleInfoDial og::SingleInfoD ialog(const
PlayableSetBase &)':
test.cpp:2: error: `class PlayableSetBase ' is inaccessible
test.cpp:24: error: within this context

Obviosly gcc does not manage to pass the parameter of type const
PlayableSetBase & to the constructor of InfoDialog because there is a
private base class with the same name. Is this really not allowed?
Marcel
-----
class PlayableSetBase
{
};

class OwnedPlayableSe t
: public PlayableSetBase
{public:
OwnedPlayableSe t(const PlayableSetBase & r);
};
class InfoDialog
// a member is not sufficient because of the destruction sequence
: private OwnedPlayableSe t
{protected:
InfoDialog(cons t PlayableSetBase & key)
: OwnedPlayableSe t(key)
{}
};

class SingleInfoDialo g
: public InfoDialog
{public:
SingleInfoDialo g(const PlayableSetBase & key)
: InfoDialog(key) // <-- !!!
{}
};
Nov 18 '08 #1
3 5259
Marcel Müller wrote:
In the code below gcc says

test.cpp: In constructor `SingleInfoDial og::SingleInfoD ialog(const
PlayableSetBase &)':
test.cpp:2: error: `class PlayableSetBase ' is inaccessible
test.cpp:24: error: within this context

Obviosly gcc does not manage to pass the parameter of type const
PlayableSetBase & to the constructor of InfoDialog because there is a
private base class with the same name. Is this really not allowed?
It's probably a quirk of the lookup rules, which can be exacerbated by
g++'s inability to interpret them correctly. Try supplying '::', like I
show below.
>

Marcel
-----
class PlayableSetBase
{
};

class OwnedPlayableSe t
: public PlayableSetBase
{public:
OwnedPlayableSe t(const PlayableSetBase & r);
};
class InfoDialog
// a member is not sufficient because of the destruction sequence
: private OwnedPlayableSe t
{protected:
InfoDialog(cons t PlayableSetBase & key)
: OwnedPlayableSe t(key)
{}
};

class SingleInfoDialo g
: public InfoDialog
{public:
SingleInfoDialo g(const PlayableSetBase & key)
Try replacing this with

SingleInfoDialo g(const ::PlayableSetBa se& key)
: InfoDialog(key) // <-- !!!
{}
};
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Nov 18 '08 #2
Marcel Müller wrote:
In the code below gcc says

test.cpp: In constructor `SingleInfoDial og::SingleInfoD ialog(const
PlayableSetBase &)':
test.cpp:2: error: `class PlayableSetBase ' is inaccessible
test.cpp:24: error: within this context

Obviosly gcc does not manage to pass the parameter of type const
PlayableSetBase & to the constructor of InfoDialog because there is a
private base class with the same name. Is this really not allowed?
There's not just a private base class with that name, but also the name
of that base class is implicitly introduced into the derived class'
scope (it is called "base class name injection"). Class
'PlayableSetBas e' is a base class of class 'OwnedPlayableS et', which
means that 'PlayableSetBas e' is injected into the 'OwnedPlayableS et'
scope, as if an invisible typedef declaration was there

class OwnedPlayableSe t
: public PlayableSetBase
{ public:
...
typedef ::PlayableSetBa se PlayableSetBase ;
...
};

Now, whenever you use the unqualified 'PlayableSetBas e' in any derived
class, it actually refers not to the file-scope name, but to that
class-scope name implicitly declared in 'OwnedPlayableS et'.

In your example, 'InfoDialog' inherits from 'OwnedPlayableS et'
privately, meaning that now 'PlayableSetBas e' is private in
'InfoDialog'. And finally, you are trying to access the private
'PlayableSetBas e' from 'SingleInfoDial og', which causes the error.

To fix the error, tell the compiler that you want to refer to the global
'PlayableSetBas e' name, not the inherited private 'PlayableSetBas e' name.

class SingleInfoDialo g
: public InfoDialog
{public:
SingleInfoDialo g(const ::PlayableSetBa se& key)
: InfoDialog(key)
{}
};
>
-----
class PlayableSetBase
{
};

class OwnedPlayableSe t
: public PlayableSetBase
{public:
OwnedPlayableSe t(const PlayableSetBase & r);
};
class InfoDialog
// a member is not sufficient because of the destruction sequence
: private OwnedPlayableSe t
{protected:
InfoDialog(cons t PlayableSetBase & key)
: OwnedPlayableSe t(key)
{}
};

class SingleInfoDialo g
: public InfoDialog
{public:
SingleInfoDialo g(const PlayableSetBase & key)
: InfoDialog(key) // <-- !!!
{}
};
--
Best regards,
Andrey Tarasevich
Nov 18 '08 #3
Hi!

Andrey Tarasevich wrote:
Marcel Müller wrote:
>In the code below gcc says

test.cpp: In constructor `SingleInfoDial og::SingleInfoD ialog(const
PlayableSetBase &)':
test.cpp:2: error: `class PlayableSetBase ' is inaccessible
test.cpp:24: error: within this context

Obviosly gcc does not manage to pass the parameter of type const
PlayableSetBas e& to the constructor of InfoDialog because there is a
private base class with the same name. Is this really not allowed?

There's not just a private base class with that name, but also the name
of that base class is implicitly introduced into the derived class'
scope (it is called "base class name injection"). Class
'PlayableSetBas e' is a base class of class 'OwnedPlayableS et', which
means that 'PlayableSetBas e' is injected into the 'OwnedPlayableS et'
scope, as if an invisible typedef declaration was there
[...]

Thanks! This was the decisive hint.

I was a bit confused because the error came at the line with the copy
constructor invocation rather that the functions argument list.

To fix the error, tell the compiler that you want to refer to the global
'PlayableSetBas e' name, not the inherited private 'PlayableSetBas e' name.

class SingleInfoDialo g
: public InfoDialog
{public:
SingleInfoDialo g(const ::PlayableSetBa se& key)
: InfoDialog(key)
{}
};
That works as expected.

I only wonder a bit why

SingleInfoDialo g::SingleInfoDi alog(const PlayableSetBase & key) {}

does not give a similar error (assuming a suitable default constructor
of InfoDialog). Types of member function arguments are normally resolved
from within the class scope too.
Marcel
Nov 21 '08 #4

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

Similar topics

2
4363
by: AIM | last post by:
Error in msvc in building inheritance.obj to build hello.pyd Hello, I am trying to build the boost 1.31.0 sample extension hello.cpp. I can not compile the file inheritance.cpp because the two files containing some templates: adjacency_list.hpp and mem_fn.hpp can not compile. Does anyone have any solutions?
1
1274
by: cmelnick | last post by:
I created an interface, IMyInterface and placed it in namespace MyPackage. Something like this: namespace MyPackage { interface IMyInterface { // Stuff } } This interface as well as some other stuff gets built into a DLL.
6
1773
by: WindAndWaves | last post by:
Hi Gurus The page below has a strange error. It seems to be working very well, just when you enter 8 or 9 for day, month or year then you get an error. I really have no idea where that is coming from. Can you help? <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <HTML> <HEAD>
7
1472
by: VB Programmer | last post by:
(Using Whidbey, but I don't think it matters.) I keep getting this error: System.NullReferenceException: Object reference not set to an instance of an object. Here is the line it's happening to: dv.RowFilter = "CustomerID='" & value & "'" (It is happening in the property "Set" code below.)
2
1354
by: amita | last post by:
when i am writing a program in c# using windows app I am getting this error message as System.Windows.Forms.Control.Text is inaccessable due to its protection level. In the design window when i am placing some controls like textbox,label and button.---my code the code displayed is as follows public class form1:system.windows.forms.form...
1
3270
by: developer | last post by:
Hi All I have made a .NET project. the files included are borland c++ files that i am migrate to VC++ .NET I am using Microsoft Visual C++ .NET 2003. the compilation goes through properly, but throws a load of linker errors
2
2738
by: dasilva109 | last post by:
Hi guys I am new to C++ and need urgent help with this part of my code for a uni coursework I have to submit by Thursday //ClientData.h #ifndef CLIENTDATA_H #define CLIENTDATA_H #include <string>
6
121863
by: sadegh | last post by:
Hi I have a problem with my program in VC++6 When I compile it, the following errors are listed. I spend a lot of time on the groups.google.com to find its reason, but none of comments could not help me. Does any body know what is the problem?. Thanks. OtherFunctions.obj : error LNK2001: unresolved external symbol "int
0
7351
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7744
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7350
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7691
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5276
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3392
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1819
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
973
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
639
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.