Advertisement
Guest User

Untitled

a guest
Dec 14th, 2018
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.39 KB | None | 0 0
  1. // instead of unspecific-typed arguments
  2.  
  3. Pizza makePizza(int piperoni_cnt, int jalapeno_cnt);
  4.  
  5. // use field-specific type
  6.  
  7. Pizza makePizza(Piperoni piperoni, Jalapeno jalapeno);
  8.  
  9.  
  10.  
  11. int main() {
  12.   auto p = makePizza(3, 1); // huh, what 3? what 1?
  13.  
  14.   auto p = makePizza(Piperoni{Parts{3}}, // 3 parts of piperoni
  15.                      Jalapeno{Parts{1}}); // 1 part of jalapeno (hot!)
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement