Sound designer/Game Developer based in South Yorkshire, UK

Report RSS c++ Constructor initialization, reference

Posted by on

c++

int x
int* px = &x;
int& y = *px;

//y is now an int pointing to exactly the same data as x

initialisation list:-

class aclass
{
public:
    const int intvalue;
    const int intvalue2;
 
    aclass() : intvalue(23),intvalue2(25)//constructor
    {
     //stuff - intvalue = 23, but it could not be set here!
    }
};

c++ ref

int x = 9;
int &y = x;
Post a comment
Sign in or join with:

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.

Level
Avatar
Avatar
Last Online
Country
United Kingdom United Kingdom
Gender
Male
Friends
Become friends
Member watch
Follow
Blog
Browse
Blogs
Report
Report
Share