here's an example program that creates a vector of user-given size M using the new operator: #include <iostream> #include <vector> using namespace std; // Function to create a vector of given size using new operator vector<int>* createVector(int size) { return new vector<int>(size); } int main() { int M; cout << "Enter the size of vector: "; cin >> M; // Create vector using new operator vector<int>* myVector = createVector(M); // Display vector size cout << "Vector size: " << myVector->size() << endl; // Deallocate memory used by vector delete myVector; return 0; } In this program, we define a function called createVector that takes an integer argument size and returns a pointer to a new std::vector<int> object created using the new operator with the specified ...
This blog is about providing theory as well as simple executable codes of different programming languages such as java, C, C++, and web programming, etc. This blog will be helpful to the IT students to learn about programming.