StaffCoder
C+
C++C++
6 modules · 26 challengesSign up
Module 4 of 6 · 4 challenges

C++ References & const

Learn how to change a caller's variables through references, read without copying through const references, hand back several results through out-parameters, swap and transfer values safely, and keep an account ledger with the right parameter types.
Finish every challenge, or complete the star challenge, to complete the module.

Challenges

4 challenges

Balance Adjustments

Sign up to unlock
—No data yeteasy
About this challenge

Choose between pass by value and pass by reference so deposits and withdrawals change the caller's balance while a fee preview leaves it alone.

Solved in a browser IDE and graded by tests. Sign up to solve

Statement Labels

Sign up to unlock
—No data yeteasy
About this challenge

Use reference out-parameters and read-only const references to split a customer name into two fields, tidy a stored name in place and mask an account number.

Solved in a browser IDE and graded by tests. Sign up to solve

Transfer Swaps

Sign up to unlock
—No data yeteasy
About this challenge

Swap and move values through reference parameters, and return a result by value so it stays independent of the caller's variables.

Solved in a browser IDE and graded by tests. Sign up to solve

Account Ledger

STAR
Solving it completes the module
—No data yeteasy
About this challenge

Build a one-account ledger from plain variables, choosing value, reference or const reference for every parameter and return so postings, renames, fees and transfers reach the caller while previews and copies do not.

Solved in a browser IDE and graded by tests. Sign up to solve

We use cookies that are necessary to run Staffcoder, and optional analytics cookies to see which pages get used. Analytics stays off unless you accept. Read our Cookie Policy.