Search code examples
c++functionobjectmethods

function call by function call with object in c++


I want to call the function show() by calling the function folder() with the help of an object. obj.folder() -> show(); Here, the function show() is not doing its job.

#include<iostream>
using namespace std;
int count=0;

class file{
    int roll;
    public:
        void folder()
        {
            ++count;
            roll=count;
            void show();
        }
        void show(){cout<<roll<<endl;}
};
int main()
{
    file obj;
    obj.folder();
}

Solution

  • My dude, you did not call show inside folder, u just declared a global function void show() instead.