Hello everyone, my first question is that in the code that follows, I think I understand why &a and &b have the output, but I have no idea how b, a and a++ all share the same output of 10, considering that if I duplicate the last line the second "cout << a++ <<endl;" actually outputs 11. And question number 2 is are constructors considered class member functions(methods)?
#include <iostream>
using namespace std;
int main ()
{
int a = 10;
int& b = a;
cout << &b << endl;
a++;
cout << &a << endl;
b = b - 1;
cout << b << endl;
cout << a << endl;
cout << a++ << endl;
#include <iostream>
usingnamespace std;
int main ()
{
int a = 10;
int& b = a;//b's address is = to a's address
cout << &b << endl;//prints memory address
a++;//makes a = 11
cout << &a << endl;//notethe address is the same as b's
b = b - 1;//makes a = 10
cout << b << endl;
cout << a << endl;
cout << a++ << endl;//makes a = 11 but not untill after it is used (output)
return 0;
}