Class class member function

can some one explain me this how to access one member function from another..thanks

1
2
3
4
5
6
7
8
9
10
11
12
13
 class A{

    //data members

    void foo()
    {
        bar();
    }
    void bar()
    {

    }
}//end of class A 
Like you did.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <iostream>
class A{
    //data members
public:
    void foo()
    {
      std::cout << "In foo\n";
        bar();
    }
    void bar()
    {
      std::cout << "In bar - cheers!\n";
    }
};//end of class A

int main()
{
  A a;
  a.foo();
  return 0;
}
======
$ g++ foo.cpp
$ ./a.out 
In foo
In bar - cheers!


Either you didn't try this simple test, or your attempt to paraphrase the problem completely missed out the real problem you're having.
Last edited on
got it

no i had some confusion it is clear now
Topic archived. No new replies allowed.