C++ Vectors vs Arrays

#include <vector>vector<int> v;for( int i=1; i < 5 ;i++) v.push_back(i); #include <iostream> #include <vector> using namespace std; int main() { vector<int> g1; for (int i = 1; i <= 5; i++) g1.push_back(i); cout << "Output of begin and end: "; for (auto i = g1.begin(); i != g1.end(); ++i) cout << *i << " "; } Line 2: #include <vector> // Use of...
Read More

C++ Pointers and References

int var = 10;int *ptr;ptr = &var;std::cout << "Address of var is " << &var << std::endl;std::cout << "Value of var is " << *ptr << std::endl; Why we need C++ Pointers and References C++ pointers are not difficult to learn. In truth, there are a few C++ tasks that are performed more easily with pointers, and other C++ tasks, such as dynamic memory...
Read More