The difference | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 4

The difference

In Java I can do this : class Program extends Vector { } why can't I do this in c++ class Program : public vector { }; can AnyOne tell me why??

25th May 2017, 5:39 AM
Luyanda
Luyanda - avatar
2 Answers
+ 1
vector is a template class, so you'd have to implement the template parameter(s), like so template <class T, class Alloc = std::allocator<T>> class Program : public std::vector<T, Alloc> { ... };
25th May 2017, 1:09 PM
Madera Oxidada
Madera Oxidada - avatar
+ 2
@Madera That means I can do it. but I didn't know how. Thank you.
25th May 2017, 1:39 PM
Luyanda
Luyanda - avatar