Expand|Select|Wrap|Line Numbers
- #include <iostream>
- #include <vector>
- using namespace std;
- template <class A, typename B>
- class AClass
- {
- private:
- vector<A> aVector;
- public:
- void AFunc(A t1)
- { aVector.push_back(t1);
- }
- B get_aV(B i){
- return aVector[i].get_a();
- }
- };
- class BClass {
- private:
- int a,b,c;
- public:
- BClass (int a1, int b1, int c1) : a(a1), b(b1), c(c1) {}
- int get_a() {
- return a;
- }
- };
- int main() {
- int a,b,c;
- //ordinarily a,b,c are entered from the keyboard(excluded)
- AClass<BClass,int> x;
- //later the user has the option of using the old values entered so
- AClass.AFunc(BClass (a,b,c));
- a = AClass.get_aV(1);
- //same for b and c respectively
- return 0;
- }