Omgili - forum search, search forums  
  

Discussions about base pointer

Displaying 1 - 10 out of 32,244 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.
The pointer of derived class returned by new can be type cast to the pointer of its base class. Is this true or false? I know dynamic_cast can be used to cast downside. Generally, how to cast a pointer of derived class to a pointer of its base class?
Started by on , 5 posts by 5 people.  
On the one hand,....
Thus_as_a_b_ptr = my_d_ptr; Casting a pointer to a derived to a pointer to base should be implicit.
Conversion from a pointer to a derived class to a pointer to a base class is implicit.
I have this code to represent bank: class Bank { friend class InvestmentMethod; std::vector<BaseBankAccount*> accounts; public: //... BaseBankAccount is an abstract class for all accounts in a bank: class BaseBankAccount { public: BaseBankAccount...
Started by on , 5 posts by 5 people.  
If the case is the former, then downcasting, while ugly, may specific subtypes differently, and... .
I am also assuming that everything is virtual in your base class and you just omitted (the interface of the base class).
With a dynamic_cast.
Using this example coming from wikipedia, in which DrawSquare() calls DrawLine(), could anyone explain me what the ebp and esp are in this context? From what I see, I'd say the stack pointer points always to the top of the stack, and the base pointer ...
Started by on , 8 posts by 8 people.  
The base pointer points to the memory location of the instruction that's being into program memory sequentially....
Frame's base pointer, which enables stack walking in a debugger and viewing other frames local full one I'm unsure of).
Ask your Facebook Friends
Class Base { public: virtual void foo() {} }; class Derived: public Base { public: virtual void foo() {} }; int main() { Base *pBase = NULL; Base objBase; Derived objDerived; pBase = &objDerived; pBase->foo(); /*Here Derived class foo will be called...
Started by on , 4 posts by 4 people.  
PBase->Base::foo() You can do it through scope resolution operator :: Something like this: pBase->Base::foo() Both responses above are correct...But be careful, if you need to do that, maybe.
I'm programming C++ with normal pointers, but I have heard about libraries like Boost that implement smart pointers and I have seen that in Ogre3D rendering engine there is a deep use of shared pointers. What's exactly the difference between the three...
Started by on , 5 posts by 5 people.  
It is a stack-allocated object that wraps....
In general, only use shared that cover many types; I'll assume you meant scoped pointer which uses the RAII pattern.
Of the pointer exist, and only clean up the memory when the count reaches zero.
I want to know the runtime type of a base class pointer, I know you can use dynamic_cast. is there any better way?
Started by on , 3 posts by 3 people.  
You should never need to know about the unbounded set of types that can be derived from a base type..
I have inherited a large c++ code base and I have a task to avoid any null pointer exceptions that can happen in the code base. Are there are static analysis tools available, I am thinking lint, that you have used successfully. What other things do you...
Started by on , 7 posts by 7 people.  
I once worked on a code base where the habit was upon entry into a function, to first check for any null not apply and your code base ....
A dynamic runtime tool like Valgrind (free) If you are mainly maintaining the code base, One.
( Objective C ) How would I call a base class function using a derived pointer where foo is overridden in the derived class. Essentially the equivalent of this C++ code base* b_ptr = 0 ; derived* d_ptr = new derived() ; d->base::foo() ; I would think...
Started by on , 3 posts by 3 people.  
This from inside the class, using the super keyword - (int)doSomething { NSLog(@"calling doSomething on base]; // call doSomething on base class struct objc_super b = { .receiver = d, .class = class_getSuperclass([d.
Do you have to pass delete the same pointer that was returned by new, or can you pass it a pointer to one of the classes base types? For example: class Base { public: virtual ~Base(); ... }; class IFoo { public: virtual ~IFoo() {} virtual void DoSomething...
Started by on , 3 posts by 3 people.  
You call operator delete on the base class pointer, it uses dynamic dispatch to figure out howYes, it will work, if and only if the base class destructor is virtual, which you have done for the Base base class but not....
I have a template class that I've subclassed with a pointer to it (Decorator pattern). I added a getBase() call to return the pointer to the base class for any further subclasses. However, when I use that getBase() and call the base classes only method...
Started by on , 4 posts by 4 people.  
It should be returning the correct type of the base class: template() { return base_ ; } private....
As to why the compiler is whining about is returning the wrong type .
base (due to inheritance) and a fake one via that pointer.
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