Answers for "c++ functions dynamic vector"

C++
0

c++ functions dynamic vector

void FreeMemory(string *&v) {
    if (v != nullptr) {
        delete[] v;
        v = nullptr;
    }

}

void AssignMemory(string *&v, int n) {
    if (v != nullptr) {
        FreeMemory(v);        
    }
    if (n>=0) {
        v = new string[n];
    }
}
Posted by: Guest on May-15-2021

Browse Popular Code Answers by Language