Quick class question

If I wanted to call a member function inside another member function, how would I do that, if it's possible?

For example, if I have Find(int key) defined already and wanted to call it while i was overloading operator+.

Thanks
Turns out my operator+ has to const which is why I can't.
Just call it.

1
2
3
4
5
6
7
8
9
10
11
12
13
#include <iostream>

struct A
{
    int foo( int i ) { std::cout << "A::foo(int)\n" ; return i+3 ; }
    int twice_foo( int i ) { return foo(i) * 2 ; }
};

int main()
{
    A a ;
    std::cout << a.twice_foo(7) << '\n' ;
}



EDIT: > Turns out my operator+ has to const which is why I can't.

Add const to Find(int key)
Last edited on
Topic archived. No new replies allowed.