156k views
2 votes
use of class template 'vector' requires template arguments; argument deduction not allowed in function prototype

1 Answer

3 votes

Final answer:

The question pertains to a C++ vector template error, indicating the need to specify template arguments when using the STL vector class.

Step-by-step explanation:

The error message you’re encountering suggests that you’re trying to use the vector class template in C++ without specifying its template arguments. In C++, a vector is a dynamic array that can grow in size, as elements are added to it. It is part of the Standard Template Library (STL), which provides a collection of generic classes and functions. When declaring a vector, you must specify the type of elements it will hold, using angle brackets (< and >). For example, to declare a vector of integers, you would write std::vector<int>. Without this specification, the compiler does not know what type of elements the vector is supposed to contain and thus cannot proceed with the function prototype.

The error message you are encountering is related to the usage of class template 'vector' in your code. In C++, when using a class template like 'vector', you need to provide template arguments specifying the type of elements the vector will hold. For example, if you want to create a vector that holds integers, you would write vector myVector;.

If you omit the template arguments or provide incorrect arguments, you will encounter the error message you mentioned. Make sure to include the appropriate template arguments when using the 'vector' class template.

User Reno Anthus
by
8.0k points