Блог пользователя khanhdungtrinh

Автор khanhdungtrinh, история, 3 года назад, По-английски

This code is from: https://codeforces.me/blog/entry/86731 ~~~~~ struct Line { data_t a, b;

Line() : a(0), b(-inf) {} Line(data_t a, data_t b) : a(a), b(b) {}

data_t get(data_t x) { return a * x + b; } }; ~~~~~

I have no idea what the colon marks in the code means?

  • Проголосовать: нравится
  • +2
  • Проголосовать: не нравится

»
3 года назад, скрыть # |
 
Проголосовать: нравится +10 Проголосовать: не нравится

It is used in constructors to initialize member variables of classes/structs. The variables outside the parentheses are member variables and the values within the corresponding parentheses are the values to which you initialize the member variables.

This is generally the preferred method of initializing values in classes/structs when possible.