搜尋此網誌

2025年8月26日星期二

Writing functions in C++

std::string name = "Alice";

A function prototype in C++ is a declaration of a function that tells the compiler about the function's name, return type, and parameters—without actually defining what the function does.

When we say "a function doesn't return a value" in C++, we mean that the function performs its task but doesn't give any result back to the part of the program that called it. Imagine you ask someone to turn off the lights. They do it, but they don’t hand you anything afterward—they just complete the action. That’s a void function.

string& in C++ means you're working with a reference to a std::string object.

In C++, a function is a reusable block of code that performs a specific task. When you call a function, it can either return a value or simply perform an action without returning anything.

In C++, an identifier is the name used to identify a variable, function, class, array, or any other user-defined element.

Microsoft Copilot

沒有留言:

發佈留言