#include <iostream>
#include<stdlib.h>
using namespace std;
class test{
public:
test(int a):i(a){
}
int display();
private:
int i;
};
int test::display(){
i;
}
int main() {
test obj(10);
cout<<obj.display();
return 0;
}
In above case some random value is printed. But when I changed function declaration as :
int& display();
and definition as :
int& test::display(){
i;
}
It displayed correct value i.e. 10 I don't know why?