Set your Publisher ID in src/config/ads.ts to display live ads.
References vs Pointers & Const Correctness
Pass-by-reference without pointer syntax and const correctness guarantees
C++ introduced References (&), which act as permanent aliases to existing objects. Unlike pointers, references cannot be null and cannot be reseated.
References and Const Correctness
Reference (int &ref = original): An alias for an existing variable. Modifying ref modifies original directly.
Pass-by-Const-Reference (const std::string &str): The golden standard in C++! Passes large objects without expensive memory copies while guaranteeing the function cannot modify the original.
#include <iostream>
#include <string>
// Efficient: Zero string copy, guaranteed read-only
void printBanner(const std::string &text) {
std::cout << "=== " << text << " ===" << std::endl;
}
int main() {
std::string title = "Codexia High Performance C++";
printBanner(title); // Passes lightweight reference
return 0;
}Set your Publisher ID in src/config/ads.ts to display live ads.
Test Yourself With Exercise
Why is `const std::string ¶m` the preferred convention for passing strings and objects into C++ functions?