#include<iostream>
#include<cstring>
#include<cstdio>
#include<cstdlib>
using namespace std;
class StringStack{
static const int size = ;
const string* stack[size];
int index;
public:
StringStack();
void push(const string* s);
const string* pop(); }; StringStack::StringStack() :index(){
memset(stack, , size*sizeof(string*));
} void StringStack::push(const string* s){
if (index<size)
stack[index++] = s;
} const string* StringStack::pop(){
if (index>){
--index;
const string* rv = stack[index];
stack[index] = ;
return rv;
} return ; } string iceCream[] = { "pralines & cream", "fudege ripple", "jamocha almond fudge", "wild mountain blackberry",
"raspberry sorbet", "lemon swirl", "rocky road", "deep chocolate fudge" }; const int iCsz = sizeof(iceCream) / (sizeof(*iceCream)); int main(){ StringStack ss;
for (int i = ; i<iCsz; i++)
ss.push(&iceCream[i]);
const string* cp;
while ((cp = ss.pop()) != )
cout << *cp << endl;//报错:
system("pause");
return ; }
2 IntelliSense: 没有与这些操作数匹配的 "<<" 运算符
操作数类型为: std::ostream << const std::string d:\programmer practice\thinking in c++\08\ConstInClass\ConstInClass\constInClass.cpp 61 8 ConstInClass