64,637
社区成员
发帖
与我相关
我的任务
分享
template <class DataType>
class stack
{
public:
stack(int size)
{
m_size = size;
m_current = -1 ; // initialize stack
m_data = new DataType[size] ;
}
int push(const DataType &data)
{
if (m_current<6)
{
m_current++;
m_data[m_current]=data;
return 1;
}
else
{
return 0;
}
void print()
{
cout<<"print data"<<endl;
for (int i=0;i<=m_current;i++)
{
cout<<m_data[i]<<";";
}
cout<<endl;
}
private:
int m_size ; // number of elements on Stack.
int m_current ;
DataType* m_data ;
}
void breakValue(char line[])
{
char *p;
p=strtok(line,",");
if (p)
{
cout<<p<<";"<<endl;
}
cout<<"AFTER break "<<endl;
while(p)
{
p=strtok(NULL,",");
if(p)
{
num=atof(p);
cout<<num<<"; ";
intVec.push(num);
}
}
}
void openfile()
{
int i=0;
inFile.open(m_str1.c_str());
if (!inFile)
{
cout << "Unable to open file";
}
if (getline(inFile,m_string))
{
while(inFile.getline(word,256))
{
cout<<"before break "<<word<<endl<<endl;
breakValue(word);
}
}
}