Jump to content

What does this do

RexLee
Go to solution Solved by WanderingFool,

It is a constructor.  Basically it is turning the struct into a pseudo-class

 

The _x(x) is just initiallizing the _x to x...it is suppose to be more efficient than doing

 

_x = x inside the actual constructor (or at least that is what my teacher said a long time ago...not sure if it is actually true)

I was looking at some code. (C++)

struct isValue{    isValue(int x): _x(x){};    bool operator()(std::pair<int,int> v)    {        return v.second == _x;    }             int _x;};

But I don't understand this line:

isValue(int x): _x(x){};

What does it do?

Link to comment
Share on other sites

Link to post
Share on other sites

It is a constructor.  Basically it is turning the struct into a pseudo-class

 

The _x(x) is just initiallizing the _x to x...it is suppose to be more efficient than doing

 

_x = x inside the actual constructor (or at least that is what my teacher said a long time ago...not sure if it is actually true)

0b10111010 10101101 11110000 00001101

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×