Multiple Parameters Trong C++

Multiple Parameters Trong C++
Rate this post

Multiple Parameters

Bên trong hàm, bạn có thể thêm bao nhiêu tham số tùy thích:

Example

void myFunction(string fname, int age) {
  cout << fname << " Refsnes. " << age << " years old. \n";
}

int main() {
  myFunction("Liam", 3);
  myFunction("Jenny", 14);
  myFunction("Anja", 30);
  return 0;
}

// Liam Refsnes. 3 years old.
// Jenny Refsnes. 14 years old.
// Anja Refsnes. 30 years old.

Lưu ý rằng khi bạn đang làm việc với nhiều tham số, lời gọi hàm phải có cùng số đối số vì có tham số và các đối số phải được truyền theo cùng một thứ tự.

0 / 5 - (0 Đánh Giá)

Leave a Reply

Your email address will not be published. Required fields are marked *

PHP Code Snippets Powered By : XYZScripts.com
.
.
.
.