Browse DevX
Sign up for e-mail newsletters from DevX

Search the Tips
Tip Bank > C++ > Virtual Functions

Virtual Functions

1-20 of 21     Previous     Next
Calling a Virtual Method from a Non-Virtual Method
by Venkata Edara
How can you tell which f2() will be invoked: A::f2() method or B::f2()?
Pure Virtual Functions Declared as Private in C++ Classes
by Alexander Ocher
How can a pure virtual function be private? Will the derived class be able to override it? Actually, it's possible for pure virtual functions to have any access modifier: private, protected, or public.
Using a Function Call as an Lvalue
by Ron Stevenhaagen
Learn how to use a function call as an Lvalue.
Visual Inheritance with C#
by Boris Eligulashvili
Microsoft VS.NET provides design-time support for form inheritance. A derived form can be added to your solution by right-clicking on your project in the Solution Explorer window and choosing "Add..." and then "Add Inherited Form…" from the context menu.
When to Use Virtual Functions
by Sophy Pal
This tip demonstrates how to use virtual functions when you override a base method.
Qualified Calls
by Danny Kalev
A function call such as the ...
Inlining Virtual Member Functions
by Danny Kalev
Generally, compilers can't inline a virtual function call if the it's resolved dynamically. Therefore, declaring a virtual member function inline might seem pointless. However, not every call of a ...
Virtual and Non-Virtual
by DevX Pro
Why would a call to a virtual function execute slower than a call to a non-virtual function?
Calling a Virtual Member Function From a Constructor
by Danny Kalev
< ...
To Virtual Or Not To Virtual?
by Danny Kalev
< ...
The Importance of Virtual Destructors
by Danny Kalev
Some classes in the Standard Library do not have a virtual destructor or virtual member functions by design. These classes include std::string, std::complex, and all STL containers. The lack of a ...
Preventing Program's Crash due to a Pure Virtual Function's Call
by Danny Kalev
A pure function should never be invoked. However, a buggy program or a buggy compiler can sometimes call a pure virtual function. In general, when a pure virtual function is invoked, the program ...
Converting a Virtual Member Function to a Pure Virtual One in a Derived Class
by Danny Kalev
In general, a derived class that inherits a pure virtual member function from its abstract base class implements this function. The opposite is also true: a virtual member function that is ...
Accessing a C++ Object in C Code: Support for Virtual Member Functions
by Danny Kalev
In the case of virtual functions, an additional member is inserted into the class: a pointer to the virtual table, or _vptr. The _vptr holds the address of a static table of function pointers. The ...
Simulating Virtual Constructors
by Danny Kalev
A constructor may not be declared virtual. The easiest way to simulate virtual construction is by defining a virtual member function that returns a constructed object of its class ...
When to Use a Pure Virtual Member Function
by Danny Kalev
A pure virtual function is merely an interface and can be thought of as a way to enforce policy. A pure virtual function should be used when subclasses implement the same interface completely ...
Overloading a Member Function Across Class Boundaries
by Danny Kalev
Since a class is a namespace, the scope for overloading a member function is confined to the class containing this function. Sometimes, it is necessary to overload the same function in its class as ...
Default Arguments in Virtual Functions Must be Identical
by Danny Kalev
You should pay attention when using default arguments in virtual functions. The default values in the overriding function have to be identical to the corresponding default values in the base class. ...
Access Specification of a Virtual Method Should not Change in a Derived Class
by Danny Kalev
The access specification of a public virtual member function defined in a base class, can be changed in a derived ...
Return type of an overriding virtual member function
by Danny Kalev
Once declared virtual, a member function can be overridden in any level of derivation, as long as the overriding version has the identical signature of the original declaration. This is quite ...
1-20 of 21     Previous     Next
Thanks for your registration, follow us on our social networks to keep up-to-date