1
:material-circle-edit-outline: 约 144 个字 :fontawesome-solid-code: 7 行代码 :material-clock-time-two-outline: 预计阅读时间 1 分钟
For the code below
- Which statement is RIGHT for the line in function f()?
- This is a variable definition, while students is an object of Stash, initialized w/ default ctor.
- This is a function prototype, while students is a function returns an object of Stash.
- This is a function call.
- This is illegal in C++.
Correct Usages:
Function Prototype:
Variable Definition:
Function Call (assuming students is a defined function):
Copying
Create a new object from an existing one
Copying is implemented by the copy constructor
- Has the unique signature
T::T(const T&);
C++ builds a copy ctor for you if you don't provide one!
What if class contains pointers? Choices!
Character strings
In C++, a character string is an array of characters with a special terminator — ‘\0’
or ASCII null
The string “C++” is represented, in memory, by an array of four characters