I am trying to define a class which has member data corresponding to a std::array whose length is variable (defined when constructed). I think my implementation is nearly correct however I am getting this error when I attempt to compile:
Undefined symbols for architecture arm64:
"Bingo<10>::hello(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)", referenced from:
_main in sol-1dea7f.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
What am I doing incorrectly? So far I have:
bingo.h
#include <array>
#include <string>
using namespace std;
template<int size>
class Bingo
{
public:
array<array<int, size>, size> board;
void hello(string s);
};
bingo.cpp
#include <string>
#include <iostream>
#include "bingo.h"
using namespace std;
template<int size>
Bingo<size>::Bingo()
{
cout << "constructed" << endl;
}
template<int size>
void Bingo<size>::hello(string s)
{
cout << s << endl;
}
main.cpp
#include <string>
#include <fstream>
#include <iostream>
#include <array>
#include "bingo.h"
using namespace std;
int main()
{
ifstream input ("in.txt");
string line;
while (getline(input, line))
{
// cout << line << endl;
}
Bingo<10> b;
b.hello("test");
input.close();
}
Aucun commentaire:
Enregistrer un commentaire