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: 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started