From 711147f8cf76bb1f44bf20a008cc467113b72d85 Mon Sep 17 00:00:00 2001 From: Muhammad Ali Zahid <104762132+CursedSpiderBoi@users.noreply.github.com> Date: Fri, 31 Mar 2023 11:41:56 +0500 Subject: [PATCH 1/2] Added TypeDef Section --- README.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) 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 From f3f9bdcc1ca8b10f32782ff1a054ad982d7396dd Mon Sep 17 00:00:00 2001 From: Muhammad Ali Zahid <104762132+CursedSpiderBoi@users.noreply.github.com> Date: Fri, 31 Mar 2023 11:44:33 +0500 Subject: [PATCH 2/2] Update cheatsheet-as-sourcefile.cpp --- cheatsheet-as-sourcefile.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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)