Hello fellow programmers, i just finished a chapter of pointers in a beginner C++ programming book. As i was doing the end chapter exercises i have stumbled upon a error in my exercise that requests that i write a program with a pointer to a pointer to a string object. I need to use the pointer to the pointer to call the size() member function of the string object. Line 12 gives me an error message. Any ideas?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
#include <iostream>
#include <string>
usingnamespace std;
int main()
{
string* pString = 0;
string* p2String = 0;
string mystring = "String made for pointing exercise!\n";
pString = &mystring;
p2String = &pString;
cout<<"(*p2String).size() is: "<<(*p2String).size()<<"\n";
return 0;
}