You can't declare a reference variable in the class and then assign it later on. Non-reference variables and pointers can be left uninitialized but references must have a value upon entry. The only way to do this is through an initializer.
#include <iostream>In this example class a has two reference variables. One is to class refed (it's a struct but apart from all members being public, is the same as a class) and one is to an int variable.
using namespace std;
struct refed {
int rd;
};
class a {
public:
refed & r;
int x;
int ℞
a(refed & extr) : r(extr), rx(x) { }
};
void main() {
refed ref;
a A(ref) ;
A.x=9;
A.r.rd=47;
cout << "Value of rx=" << A.rx <<endl;
cout << "Value of A.r.r=" << A.r.rd <<endl;
}
Default Constructors for Ints etc
Though they are not objects, the non class types such as int, float, char and bool do have a default constructor! It doesn't allocate any memory but does initialize the variable.int a(8) ;
bool b(true) ;
and
class c {
int a;
};
c * v = new c;
int * x = new int (6) ;
On the next page Creating and Using Copy Constructors

