Edit:
- I am so sorry about the
this
and the lack of a;
at the end of my template class; I had some issues copying and pasting my code, so I copied some code by hand and messed those parts up. - After reopening the IDE, the error just magically vanished. Maybe Repl.it was having some issues. The error message is different now. If I am unable to solve this error on my own, I will ask a new question.
Thank you to HugoTeixeira, Matthew Fisher, and user4581301 for your thoughtful responses.
I have the following code in Group.h
:
template <typename T, int N> class Group
{
public:
T values[N];
Group(T args[])
{
for (int i = 0; i < N; i++)
{
values[i] = args[i];
}
}
Group()
{
Group((T[]){0, 0, 0});
}
};
and in main.cpp
, I have this code:
#include "Group.h"
int main()
{
Group<double, 3> * v1 = new Group<double, 3>();
}
When I try to run this code, my IDE gives me the error:
no matching constructor for initialization of 'Group<double, 3>'
I have tried writing this code but minus the template, and it worked fine. What am I doing wrong?