Sound designer/Game Developer based in South Yorkshire, UK

Report article RSS Feed c++ Constructor initialization, reference

Posted by TommyGoogle on Aug 23rd, 2013

c++

cpp code:
int x
int* px = &x;
int& y = *px;

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

initialisation list:-

cpp code:
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

cpp code:
int x = 9;
int &y = x;
Post a Comment
click to sign in

You are not logged in, your comment will be anonymous unless you join the community today (totally free - or sign in with your social account on the right) which we encourage all contributors to do.

2000 characters limit; HTML formatting and smileys are not supported - text only

Level
Avatar
Avatar
Offline Since
Jan 21, 2014
Country
United Kingdom United Kingdom
Gender
Male
Member Watch
Track this member
Blog
Browse
Blogs
Views
77 (1 today)
Report Abuse
Report article