Skip to main content

All Questions

0 votes
1 answer
265 views

C++ - Accessibility VS visibility

I am working on an exercise to make sense of C++'s accessibility VS visibility. The following code doesn't compile obviously, but this is what it ideally must be. B inherits from A with template ...
user avatar
1 vote
1 answer
61 views

c++ Inheritance with templates and visibility

I don't understand att all inheritance with templates.. template <typename T> class Mere { protected: Mere(); }; class Fille2 : public Mere<int> { protected: Fille2(){ ...
E A's user avatar
  • 13
2 votes
4 answers
170 views

Not able to call base class constructor from dericed class with parameter in c++

I have below scenario in c++ within DEV c++ class base{ int i=0; public: base(){ cout<<"base default constructor"<<endl; } base(int i){ ...
Ryuk's user avatar
  • 21
0 votes
3 answers
320 views

C++ virtual function from privately inherited class, promoted to public in derived class declaration

I have the following scheme: class Interface { virtual ~Interface() { } virtual void foo() const = 0; virtual void bar() const = 0; } //Interface is derived privately mostly for ...
galinette's user avatar
  • 9,162
-1 votes
2 answers
211 views

Two classes inheriting from the same base to see each other

I have a program with a lot of classes. I want classes in the program to be visible to each other. For that, I am following a trick such that all classes are inherited from a base class, which holds ...
devotee's user avatar
  • 127
4 votes
1 answer
600 views

Destructor protection in abstract base class is not inherited in C++?

I found a memory leak in my code that was caused by calling only the base class destructor for objects. This problem is understood: I already added the virtual to the destructor of the interface class ...
Wolf's user avatar
  • 9,965
3 votes
0 answers
27 views

Inherited data member in generic class not visible in derived class unless prefixed with this-> [duplicate]

I have encountered the following problem with someone else's code which presumably was compiling at some point. A base class is a generic container of a data member of type T. This data member is ...
DuncanACoulter's user avatar
6 votes
4 answers
3k views

Policy inheritance and inaccessible protected members

It seems that a protected member from a template policy class is inaccessible, even with a class hierarchy which seems correct. For instance, with the following code snippet : #include <iostream&...
benlaug's user avatar
  • 2,741
1 vote
2 answers
139 views

visibility of a nested class in an inherited class

The code I work on is roughly the following: // List.h template <typename T> class List{ template <typename TT> class Node; Node<T> *head; /* (...) */ template <...
infoholic_anonymous's user avatar
43 votes
4 answers
212k views

Calling the base class constructor from the derived class constructor

I have a question: Say I have originally these classes which I can't change (let's say because they're taken from a library which I'm using): class Animal_ { public: Animal_(); int getIdA() ...
Joy's user avatar
  • 1,767
1 vote
3 answers
199 views

Private inheritence and constructors

I have following problem: want to inherit some class as protected (outside derived class i dont need any member or function from base class) want to be able to access base constructor in some way ...
sivic's user avatar
  • 529
0 votes
1 answer
544 views

Inheritance inside a template - public members become invisible?

I'm trying to use inheritance among classes defined inside a class template (inner classes). However, the compiler (GCC) is refusing to give me access to public members in the base class. Example ...
Juliano's user avatar
  • 40.7k
1 vote
5 answers
1k views

Why is this explicit scope resolution necessary?

Setup: class A { public: void a() {} }; class B { public: void b() {} }; class C: public A, public B { public: void c() {} }; What (I thought) I should be able to do: C* foo = ...
Chris Tonkinson's user avatar