展开全部
#include<iostream>
#include<vector>
#include<string>
using namespace std;
class CString
{
private:
vector<string> q;
public:
void add();
void print();
};
void CString::add()
{
string w;
cout<<"Please input string"<<endl;
cin>>w;
q.push_back(w);
}
void CString::print()
{
cout<<endl<<"The string is:"<<endl;
for(int i = 0;i < q.size();i++)
cout<<q[i].c_str()<<endl;
cout<<endl;
}
int main()
{
CString s;
while(1)
{
s.add();
s.print();
}
return 0;
}
#include<vector>
#include<string>
using namespace std;
class CString
{
private:
vector<string> q;
public:
void add();
void print();
};
void CString::add()
{
string w;
cout<<"Please input string"<<endl;
cin>>w;
q.push_back(w);
}
void CString::print()
{
cout<<endl<<"The string is:"<<endl;
for(int i = 0;i < q.size();i++)
cout<<q[i].c_str()<<endl;
cout<<endl;
}
int main()
{
CString s;
while(1)
{
s.add();
s.print();
}
return 0;
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询