here is my code:
#include <iostream>
using namespace std;
template<typename T>
class List
{
public:
List(T);
};
template<typename T>
class A: public List<T>
{
public:
};
int main()
{ //my problem is here...!
A a(10);
}
I don't know how to declare this class in main and use it.
In this case, I have this error:
missing template arguments before ‘a’
and when I write:
template(typename T)
A a(10);
I give this error:
g++ -std=c++11 -c main.cpp error: a template declaration cannot appear at block scope template ^~~~~~~~
Since u didn't write a constructor for
A, I supposed u want to use the inherited one, hence u have to provide the following line inAAnd since u used
c++11, u have to provide the templatearg, as followsIf u want to make the compiler figure it out, use
c++17orc++20and provide the following guideNow the full code with
c++17will beAnd with
c++11will be