Advertisement
Guest User

Untitled

a guest
Feb 17th, 2019
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.37 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3.  
  4. class A{
  5.     public:
  6.     int value;
  7.     A() : value(1){}
  8.     A(int x) : value(x){}
  9. };
  10.  
  11.  
  12. template<class C>
  13. class B{
  14.     public:
  15.     std::vector<C> v;
  16. };
  17.  
  18.  
  19. int main() {
  20.     A a{100};
  21.     B<A> b{};
  22.    
  23.     b.v.push_back(a);
  24.    
  25.     std::cout << b.v[0].value << std::endl;  
  26.    
  27.    
  28.    
  29.     return 0;  
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement