Question: write a C++ program 1 Pointer and reference The purpose of this assignment is practicing pointers and references. Here, you are given an array of

write a C++ program

1 Pointer and reference The purpose of this assignment is practicing pointers and references. Here, you are given an array of pointers to strings. You need to implement a function called RemoveDupPointers that takes this array of pointers and remove the pointers that have duplicate strings. Note: you should test whether two pointers point to identical strings, not whether two pointers have the same address. Also note: dont change relative order of the pointers that are kept. For example, suppose you are given three strings: string s1=abc, s2 = bcd, s3=abc; The array of pointers: array[] = {&s1, &s2, &s3, &s1}; You invoke: RemoveDupPointers(array). Then the array should only contain: array[] = {&s1, &s2} Note: I will use C++ STL vector to represent an array. Essentially, STL vector is a better array. I want you to start to experiment with this powerful utility class. Google it to find references on how to use STL vector.

starter code

//

// RemoveDupPointers.cpp

//

//

// Created by Yufeng Wu on 1/18/21.

//

//

#include

#include

using namespace std;

//

void RemoveDupPointers(vector &arrayPtrs)

{

// arrayPtrs: STL vector of pointers to strings

// remove pointers that are pointed to identical strings in the array

// Your code goes here...

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!