From Jason Turner
Watch on YouTube

Summary

This episode explains variable shadowing in C++, which occurs when a variable declared in an inner scope has the same name as a variable in an outer scope, causing the outer variable to be temporarily inaccessible. Jason demonstrates how shadowing can lead to bugs that aren't caught by default compiler settings. He shows how to detect these issues by enabling additional compiler warnings, specifically the -Wshadow flag in GCC/Clang, which can identify potential shadowing problems before they cause runtime errors.

Resources

Tags