我想结合两个向量,但是当我尝试在屏幕上写结果时,我得到的结果没有 int 数字,它是两个。我想得到结果:一二三四 50 你能帮我吗,如何解决?谢谢
#include <iostream>
#include <string>
#include <vector>
using namespace std;
template<typename T>
class One
{
protected:
T word;
T word2;
public:
One() {word = "0"; word2 = "0";}
One(T w, T w2) {word = w; word2 = w2;}
virtual const void Show() {cout << word << endl; cout << word2 << endl;}
};
template<typename T>
class Two : public One<T>
{
protected:
int number;
public:
Two() {number = 0;}
Two(T w, T w2, int n) : One(w,w2) {number = n;}
virtual const void Show () {cout << word << endl; cout << word2 << endl; cout << number << endl; }
};
int main ()
{
vector<One<string>> x;
vector<Two<string>> x2;
One<string> css("one","two");
Two<string> csss("three","four",50);
x.push_back(css);
x2.push_back(csss);
x.insert(x.end(),x2.begin(),x2.end());
for (int i = 0; i < x.size(); i++)
{
x.at(i).Show();
}
cin.get();
cin.get();
return 0;
}