"using" in C++
1. Type Aliases (Modern Replacement for typedef)
typedef)using AliasName = ExistingType;using uint = unsigned int; uint x = 5; // Now 'uint' is an alias for 'unsigned int'typedef unsigned int uint; // Old way with typedef using uint = unsigned int; // Modern way with using
2. Importing Names from a Namespace
using namespace NamespaceName; using NamespaceName::Identifier;#include <iostream> using namespace std; // Brings all names from std into scope int main() { cout << "Hello, World!" << endl; // No need for std::cout return 0; }using std::cout; // Only brings cout into scope using std::endl;
3. Using Declarations for Base Class Members
4. Alias Templates
Summary:
Last updated