Z
Zootal
The following code will compile. I have one line commented out because it
won't compile. Why can I not do this:
//set<string>::iterator iterator = s->begin();
Why do I have to deference the set when I receive it as a pointer? Is that
just the way we are supposed to do it, or am I missing something?
-------------------------------------------------
#include <iostream>
#include <set>
#include <string>
using namespace std;
typedef set<string> StringSet;
void zoot(set<string> * s);
int main()
{
set<string> s;
s.insert("aaa");
s.insert("bbb");
zoot( &s );
return 0;
}
void zoot(set<string> * s )
{
// This won't compile - why?
//set<string>::iterator iterator = s->begin();
// dereference s, use s1, and it compiles
set<string> s1 = *s;
for( set<string>::iterator iterator1 = s1.begin();iterator1 !=
s1.end();iterator1++)
{
cout << *iterator1;
}
}
won't compile. Why can I not do this:
//set<string>::iterator iterator = s->begin();
Why do I have to deference the set when I receive it as a pointer? Is that
just the way we are supposed to do it, or am I missing something?
-------------------------------------------------
#include <iostream>
#include <set>
#include <string>
using namespace std;
typedef set<string> StringSet;
void zoot(set<string> * s);
int main()
{
set<string> s;
s.insert("aaa");
s.insert("bbb");
zoot( &s );
return 0;
}
void zoot(set<string> * s )
{
// This won't compile - why?
//set<string>::iterator iterator = s->begin();
// dereference s, use s1, and it compiles
set<string> s1 = *s;
for( set<string>::iterator iterator1 = s1.begin();iterator1 !=
s1.end();iterator1++)
{
cout << *iterator1;
}
}