Error Conversion To Inaccessible Base Class Is Not Allowed
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and expected class member or base class name policies of this site About Us Learn more about Stack Overflow the
Expected Class Name Before Token Inheritance
company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags expected class-name before ‘ ’ token c++ inheritance Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes
Can Protected Class Be Inherited
a minute: Sign up C++ inheritance - inaccessible base? up vote 75 down vote favorite 10 I seem to be unable to use a base class as a function parameter, have I messed up my inheritance? I have the following in my main: int some_ftn(Foo *f) { /* some code */ }; Bar b; some_ftn(&b); And the class Bar inheriting from c++ inheritance private Foo in such a way: class Bar : Foo { public: Bar(); //snip private: //snip }; Should this not work? I don't seem to be able to make that call in my main function c++ inheritance share|improve this question edited Nov 27 '11 at 8:30 aaaidan 3,39933875 asked Jan 31 '11 at 2:19 bandai 395146 add a comment| 2 Answers 2 active oldest votes up vote 139 down vote accepted You have to do this: class Bar : public Foo { // ... } The default inheritance type of a class in C++ is private, so any public and protected members from the base class are limited to private. struct inheritance on the other hand is public by default. share|improve this answer edited Jul 17 '15 at 15:06 Barry 101k10129274 answered Jan 31 '11 at 2:22 Andrew Noyes 2,99111013 add a comment| Did you find this question interesting? Try our newsletter Sign up for our newsletter and get our top new questions delivered to your inbox (see an example). Subscribed! Success! Please click the link in the confirmation email to activat
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business
C++ Public Inheritance Private Members
Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation
C++ Public Vs Private Vs Protected
Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like error: is an inaccessible base of you, helping each other. Join them; it only takes a minute: Sign up Inheritance: 'A' is an inaccessible base of 'B' up vote 49 down vote favorite 11 $ cat inheritance.cpp #include
LearningModern CodeNetworkingOpen SourceStorageToolsDeveloper TypeEmbedded SystemsGame DevMediaTechnical, Enterprise, HPCWebOSAll ToolsAndroid*HTML5Linux*OS X*Windows*ResourcesCode SamplesContact SupportDocumentationFree SoftwareIntel Registration CenterProduct ForumsSDKsResourcesPartner with IntelAcademic ProgramPartner SpotlightBlack Belt DeveloperDeveloper https://software.intel.com/en-us/articles/intel-c-compiler-for-windows-error-conversion-to-inaccessible-base-class-is-not-allowed MeshInnovator ProgramSuccess StoriesLearnBlogBusiness TipsEventsVideosSupportContact SupportDeveloper EvangelistsFAQsForums Search form Search https://bytes.com/topic/c/answers/650523-inaccessible-base-despite-public-inheritance Intel® C++ Compiler for Windows* - Error: conversion to inaccessible base class is not allowed By mark-sabahi (Intel), Added July 2, 2009 Translating...TranslateChinese SimplifiedChinese TraditionalEnglishFrenchGermanItalianPortugueseRussianSpanishTurkish This is a computer translation of the original content. expected class It is provided for general information only and should not be relied upon as complete or accurate. Share Tweet Share Visual C++* .NET 2003 or Visual C++ 2005 will not compile the following code. For compatibility reason, Intel® C++ Compiler will emit error conversion to a compile error when /Qvc7.1 or /Qvc8 is specified. The compiler will compile the code with a warning when the /Qvc6 option is specified. If /Qvc is not explicitly specified, the one provided in ia32 For more complete information about compiler optimizations, see our Optimization Notice. Categories: Intel® C++ Compiler Intel® Parallel Studio XE Composer Edition C/C++ Microsoft Windows* (XP, Vista, 7) ForumsTools Add a Comment Top (For technical discussions visit our developer forums. For site or software product issues contact support.) Please sign in to add a comment. Not a member? Join today Support Terms of Use *Trademarks Privacy Cookies Publications Intel® Developer Zone Newsletter Intel® Parallel Universe Magazine Look for us on: Facebook Twitter Google+ LinkedIn YouTube English 简体中文 Русский Español Português Rate Us
Post your question and get tips & solutions from a community of 418,509 IT Pros & Developers. It's quick & easy. inaccessible base despite public inheritance P: n/a Stefan Weber Hi, I have the following header file (named test.h): class Foo { public: Foo(void) {} virtual ~Foo(void) {} }; class Bar : public Foo { public: Bar(void) {} virtual ~Bar(void) {} }; with a very simple cpp file: #include "test.h" int main() { Foo* f = new Bar(); } This compiles with Visual Studio 2005, but with g++ 4.1.1 I get an error: bash-3.00$ test.cpp:4: error: Foo is an inaccessible base of Bar Acutally, I know that this error message occurs when doing something like "class Bar : private Foo" (i.e. inherit the code but withouth polymorphism). But I obviously declared to use public inheritance. Does anybody see the problem? Thanks, Stefan May 22 '07 #1 Post Reply Share this Question 9 Replies P: n/a Victor Bazarov Stefan Weber wrote: I have the following header file (named test.h): class Foo { public: Foo(void) {} virtual ~Foo(void) {} }; class Bar : public Foo { public: Bar(void) {} virtual ~Bar(void) {} }; with a very simple cpp file: #include "test.h" int main() { Foo* f = new Bar(); } This compiles with Visual Studio 2005, but with g++ 4.1.1 I get an error: bash-3.00$ test.cpp:4: error: Foo is an inaccessible base of Bar Acutally, I know that this error message occurs when doing something like "class Bar : private Foo" (i.e. inherit the code but withouth polymorphism). But I obviously declared to use public inheritance. Does anybody see the problem? The only /potential/ problem is the name of the header file. Put the code you posted in the same cpp file and compile it again (comment out 'with a very...' and the '#include'). If it compiles, the problem isn't in the code. If it doesn't, you're SOL. Get a better compiler. V -- Please remove capital 'A's when replying by e-mail I do not respond to top-posted replies, please don't ask May 22 '07 #2 P: n/a Howard "Stefan Weber"