call a class-function inside another function in same class

How can i call a function of a class inside another function of the same class?

Hi there,

you can just call it by its name, or use the this pointer:

1
2
3
4
5
6
class example
{
    void foo() { /* ... */ }
    void bar() { foo(); }
    void baz() { this->foo(); }
};


Hope that helps.

All the best,
NwN
what about virtual??
Works pretty much the same... it seems to me that what you need is a better understanding of the basics of using classes in C++.

This provides a good introduction: http://cplusplus.com/doc/tutorial/classes/

virtual is used to indicate that a member function can be overridden in a child class.
More on that here: http://cplusplus.com/doc/tutorial/polymorphism/#virtual

All the best,
NwN
Topic archived. No new replies allowed.