-2

Say I have a class:

template <int S1>
class Cont {
    private:
       std::array<int, S1> nums;
    public:
       Cont(std::array<int, S1> ns);
}

When trying to link my program, I am getting an error saying that, for example, Cont(std::array ns) is undefined. So am I doing something wrong? Or will this never work due to how arrays work?

EDIT: Sorry, I should have mentioned that the constructor is defined. I was only giving the header to illustrate what I meant.

ragesalmon
  • 627
  • 1
  • 5
  • 10

1 Answers1

3
Cont(std::array<int, S1> ns)

Is only a declaration, you need to define it as well.

like:

Cont(std::array<int, S1> ns){
    // code
}
Rana
  • 1,675
  • 3
  • 25
  • 51