I wanted to write my library, I started with a template array output function. Compiler swears: candidate template ignored: could not match const type-parameter-0-0 * 'against' char ' Where is the error?
And another question, if I need a library to be located in one directory and main.cpp in another, then I connect SMKLibrary.h to main.cpp with the address of the library directory. I compile main.cpp like this: g ++ * .cpp && a.out but I get an error. It works when all the files in the same directory, when in different is not. What should I write in the terminal to compile from two different directories at once?
main.cpp
#include <iostream> #include "SMKLibrary.h" int main() { char a[5] = {"ASFD"}; array_print(a,5); return 0; } SMKLibrary.h
#ifndef SMKLIBRARY_H #define SMKLIBRARY_H #include <iostream> template <typename T> void array_print(const T * array[], int size); #endif SMKLibrary.cpp
#include "SMKLibrary.h" template <typename T> void array_print(const T * array[], int size) { int last = size - 1; for (int i = 0; i < last; i++) { std::cout << array[i] << " "; } std::cout << array[last] << std::endl; }