stl高手请进
程序如下:我想将容器list中所存储的字符串赋给指针变量st,不知该如何
实现??还望高手指点,迭代器如何将类型转化为想要的类型?
#include <iostream>
#include <string>
#include <list>
using namespace std;
int main (void) {
list<string> Milkshakes;
list<string>::iterator MilkshakeIterator;
char *st;
Milkshakes.push_back("Chocolate");
Milkshakes.push_back("Strawberry");
Milkshakes.push_front("Lime");
Milkshakes.push_front("Vanilla");
// print the milkshakes
Milkshakes.push_front("The Milkshake Menu");
Milkshakes.push_back("*** Thats the end ***");
for (MilkshakeIterator=Milkshakes.begin();
MilkshakeIterator!=Milkshakes.end();
++MilkshakeIterator) {
// dereference the iterator to get the element
cout << *MilkshakeIterator << endl;
//-------------------------------
这里该如何处理迭代器的类型可以使char *的类型st
输出字符串的结果?????????????????
//-------------------------------
//???????????????? cout<<*st<<endl;
}
}