The output of this program seems to print 5 0 1 instead of 5 1 1. I'm unable to figure out why : So this program's printing 5 0 and 1. Shouldn't it be 5 1 1? data1++ does increment f1.data1 to 1. Where really does the 0 come from? I'm using multiple functions because I've just started learning Objects and Classes and am trying to make as many possibilities as possible. This is really confusing me.

    #include <iostream>
    using namespace std;
    
    class foo
    {
    	private:
    
    	    int data1; //private data member
    
    	public:
    
    	    foo(): data1(0) //Constructor initialising it to 0.
    	    { }
    	
    	void func(foo,foo);
    
    	void display(foo fg) const
    	{
    		cout<<data1;
    		cout<<endl;
    		cout<<fg.data1;
    	}
    };
    
    void foo::func(foo ff,foo fg)
    {
    	ff.data1=5;
    	data1++;
    	ff.display(fg);
    	cout<<endl<<data1<<endl;
    }
    int main()
    {
    	foo f1,f2;
    	f1.func(f2,f1);
    	
        return 0;
    
    }