Hi everybody, I have an exercise that says: Write a program with a pointer to a string object. Use the pointer to the pointer to call the size() member function of the string object.
I did this but it doesn't work.
#include <iostream>
#include <string>
using namespace std;
int main()
{
cout << "Assigning &str to pStr\n";
string str = "score";
string* pStr = &str; //pointer to string object
cout << "str is: " << str << "\n";
cout << "*pStr is: " << *pStr << "\n";
cout << "(*pStr).size() is: " << (*pStr).size() << "\n";