Omgili - forum search, search forums  
  

Discussions about base or member c

Displaying 1 - 10 out of 69,983 discussions.  
Time Frame: (Any time)   Minimum number of replies: (2)   Minimum number of discussing users: (0)
  |  

Page: 1   2   3   4   5   6   7   8   9   10  
Keep this page open to be updated with the newest discussions automatically.
How to access the derived class's data from one of its instances' member function that receives a pointer to the base class? I have: class Base{ public: virtual void compare(Base*)=0; }; class A: public Base{ int x; public: A(); void compare(Base*); }...
Started by on , 7 posts by 7 people.  
You might limp home with this, depending on your....
If the objects really are comparable, they should be comparable at the base class level.
Just be sure to do this.
You can use dynamic_cast to cast a base pointer to one of the derived types.
Hello. It may seems rather newbie question, but can you explain why method Der.B() cannot access protected Foo via Base class variable? This looks weird to me: public class Base { protected int Foo; } public class Der : Base { private void B(Base b) {...
Started by on , 7 posts by 7 people.  
Simply put, protected allows ....
The fact that you are inheriting from that class from .
In D you are accessing a protected member of the base class of your current class to access a protected member of another class.
Is irrelevant.
In C++, is it possible to have a child class "hide" a base class' static fields and methods? (i.e. A has a field named ABC of type int, B:A and B has a field named ABC of type int)
Started by on , 4 posts by 4 people.  
Std; class A{ public: static int a; }; class B: public A{ public: static int a; // hide base member.
Ask your Facebook Friends
Here's the scenario: I want define a base class that allocate some buffer once for all derived classes, while the size of the buffer varies among different derived classes. I could achieve it in this way: class base { public: base():size(), p_array(0)...
Started by on , 3 posts by 3 people.  
Don't you want this? class base { public: base():size(), p_array(0){} base(size_t array_size):size(array_size) { p_array.reset(new derived { public: derived(size....
I think the compiler should give an error on this .
Times a p_array.
Hello all i have this : class A { public : A(int i ) : m_S(i) { m_Pa = new Foo(*this) ; } private : int m_S ; Foo* m_Pa; } and derived class class B : public A { public : B() : A (242) { // here i like to override the A class m_Pa member but i don't know...
Started by on , 6 posts by 6 people.  
Assuming it's a private data member of type Foo* in class A, you can't directly change member function: class A { ........
What is m_Pa? You never had it declared.
You can't override member variables in a derived class, only methods.
I have a code: class AbstractQuery { virtual bool isCanBeExecuted()=0; public: AbstractQuery() {} virtual bool Execute()=0; }; class DropTableQuery: public AbstractQuery { vector< std::pair< string, string> > QueryContent; QueryValidate qv...
Started by on , 4 posts by 4 people.  
Will be called automatically in the same order that the base classes are declared, before any memberNo, in fact for it is unnecessary for the base class to have an explicitly defined constructor destructor No, not in the example you provided....
Given a typical class: struct Whatever { void Doit(); }; Whatever w; what is the best way to get the member function to be called by a C void* based callback such as pthread_create() or a signal handler ? pthread_t pid; pthread_create(&pid, 0, ... &w....
Started by on , 10 posts by 10 people.  
Pass the pointer) { MyClass* c = reinterpret_cast<....
Non-static have an implied "this" argument.
Most CThe member function MUST be static.
To your Whatever instance as the void* so that the static member can get at the instance.
If I'm creating an abstract base class, and the classes derived from it are going to have some of the same data members, is it better practice to make those members private in the abstract base class and give protected access to them? Or to not bother...
Started by on , 6 posts by 6 people.  
The base class defines what derivedHow can you make members private and give protected access? Derived class cannot access base class are talking about? If....
Anything unless they need to fill out the data member, for example.
I know that the derived class can't access the private members of the base class, so why does the derived class inherit the private members of the base class? Is there any case that it is useful? Thanks!
Started by on , 9 posts by 9 people.  
The compiler would then need the correctThe derived class doesn... .
Using 'C' casting you can cast a derived to a private base.
If you want.
If it is private, The base class can still use the private member variables & methods.
The problem: I have a C++ class with gajillion (>100) members that behave nearly identically: same type in a function, each member has the same exact code done to it as other members, e.g. assignment from a map in a constructor where map key is same...
Started by on , 13 posts by 12 people.  
Of pointers to those fields, add the addresses of all member variables in question to that vector MEMBERS\ MEMBER( int, value )\ SEP MEMBER( double, value2 )\ SEP MEMBER( std::string, value3 )\ struct FluctuatingMembers....
Page: 1   2   3   4   5   6   7   8   9   10  
More Information


Forum Search About Omgili Help Plugins Forum/Board Owners Privacy

i
In Title
In Topic
In Reply
Exclude
Boost