diff --git a/README.md b/README.md index 481ab84..ac8e8df 100644 --- a/README.md +++ b/README.md @@ -303,6 +303,27 @@ N::T t; // Use name T in namespace N using namespace N; // Make T visible without N:: ``` +## TypeDef +Used For Aliasing + +```cpp +typedef std::vector vInt; //typedef +``` +Now in code we can call vInt if we want to make a Vector of int type +```cpp +vInt v; + +v.push_back(190); +v.push_back(180); +v.push_back(10); +v.push_back(10); +v.push_back(27); + +for (auto X : v) { + cout << X << " "; +} +``` + ## `memory` (dynamic memory management) ```cpp diff --git a/cheatsheet-as-sourcefile.cpp b/cheatsheet-as-sourcefile.cpp index 0d3dedd..a09e5f8 100644 --- a/cheatsheet-as-sourcefile.cpp +++ b/cheatsheet-as-sourcefile.cpp @@ -289,6 +289,22 @@ namespace N {class T {};} // Hide name T N::T t; // Use name T in namespace N using namespace N; // Make T visible without N:: +// ## TypeDef + + +typedef std::vector vInt; //typedef +vInt v; + +v.push_back(190); +v.push_back(180); +v.push_back(10); +v.push_back(10); +v.push_back(27); + +for (auto X : v) { + cout << X << " "; +} + // ## `memory` (dynamic memory management) #include // Include memory (std namespace)