can someone tell me the difference, pros and cons of both the following functions.
Code:class Node { int data_; Node* prev_; Node* next_; public: Node(){data_ = 5;} ~Node(){}; int getdata(){return data_;} }; int main() { Node obj; cout << obj.getdata() << endl; return 0; }incase you didn't see it i added a '&' in front of the getdata member function.Code:class Node { int data_; Node* prev_; Node* next_; public: Node(){data_ = 5;} ~Node(){}; int& getdata(){return data_;} }; int main() { Node obj; cout << obj.getdata() << endl; return 0; }