#include <iostream>
#include <string>
#include <vector>
#include <list>
using namespace std;
struct A
{
public:
A()
{
i=0;
c='E';
}
~A(){}
int i;
char c;
};
void swap(int &a,int &b)
{
a=a+b;
b=a-b;
a=a-b;
}
int main()
{
int a=110,b=34;
swap(a,b);
cout<<a<<" "<<b<<endl;
vector<A> alphaVector;
A aa;
alphaVector.push_back(aa);
// for( int i=0; i < 10; i++ ) {
// //alphaVector.push_back( i + 65 );
// }
// Insert four C's into the vector
vector<A>::iterator theIterator = alphaVector.begin();
//alphaVector.insert( theIterator, 4, 'C' );
// Display the vector
for( theIterator = alphaVector.begin(); theIterator != alphaVector.end(); theIterator++ ) {
cout << (*theIterator).c<<' ';
}
return 0;
}
经测验,无论A是class还是struct,都可以正常的执行,因此,STL的容器是可以“装”user-defined type.