:m(m)

Feb 27, 2014 at 10:52am
Please, what means THIS and where does it belong to?

 
  :m(m)




Many thanks!!!
Feb 27, 2014 at 10:55am
It looks like part of an initialisation list. Have a look at:

http://www.cprogramming.com/tutorial/initialization-lists-c++.html
Feb 27, 2014 at 2:58pm
Thanks, Mikey!
It SHOULD be a part of constructor of a class...but I did not get the right point still...
Feb 27, 2014 at 3:12pm
For example,

1
2
3
4
5
6
7
8
9
10
11
#include <iostream>
struct S {
    int m;
    S(int m) : m(m) {}
};

int main()
{
    S s = 123;
    std::cout << s.m << '\n';
}
Feb 27, 2014 at 3:47pm
The first m is refers to the member variable. The second m refers to the constructor parameter.
Topic archived. No new replies allowed.