I'm trying to make an array of strings, and connect them with a linked list. The problem is we can only use arrays. The instructor said we can't use templates, vectors etc. Those are the only ways I've found to be able to do this. I don't think this is even a linked list, he wants our arrays to be handled in the parallel instead of pointing to the next element in line.
#include <iostream>
#include <string>
using namespace std;
int main ()
{
string names [4] = {"Dick", "Harry", "Sam", "Tom"};
string *nameptr[4];
for(int x = 0; x < 4; x++)
{
*nameptr[x] = names[x];
cout << nameptr[x] << " ";
cout << &nameptr[x] << endl;
}
}
What's wrong with this code? What am I missing?
I'm lost, if anyone could shed some light on this it would be great.