Помогите
Не понимаю в чем ошибка
Вроде защиту от повторного подключения поставил, но выдаёт ошибку
console_stl_out.h
#ifndef _CONSOLE_STL_OUT_H
#define _CONSOLE_STL_OUT_H
#include <iostream>
#include <vector>
#include <queue>
template<class x>
void show(x a);
template<class x>
void show(std::queue<x> a);
template<class x>
void show(std::vector<std::vector<x>> a);
#endif
console_stl_out.cpp
#include "console_stl_out.h"
template<class x>
void show(x a) {
for (auto i = a.begin(); i != a.end(); i++) {
std::cout << *i << " ";
}
std::cout << "\n";
}
template<class x>
void show(std::queue<x> a) {
while (!a.empty()) {
std::cout << a.front() << " ";
a.pop();
}
std::cout << "\n";
}
template<class x>
void show(std::vector<std::vector<x>> a) {
for (auto i = a.begin(); i != a.end(); i++) {
show(*i);
}
}
Source.cpp
#include <iostream>
#include "console_stl_out.h"
using namespace std;
int main()
{
srand(time(NULL));
vector<int> a = { 1,2,12,12,1,2 };
show(a);
cout << endl;
system("pause>null");
}
Хотя единым монолитом работает!
Source.cpp
#include <iostream>
#include <vector>
#include <queue>
//#include "console_stl_out.h"
using namespace std;
template<class x>
void show(x a);
template<class x>
void show(std::queue<x> a);
template<class x>
void show(std::vector<std::vector<x>> a);
template<class x>
void show(x a) {
for (auto i = a.begin(); i != a.end(); i++) {
std::cout << *i << " ";
}
std::cout << "\n";
}
template<class x>
void show(std::queue<x> a) {
while (!a.empty()) {
std::cout << a.front() << " ";
a.pop();
}
std::cout << "\n";
}
template<class x>
void show(std::vector<std::vector<x>> a) {
for (auto i = a.begin(); i != a.end(); i++) {
show(*i);
}
}
int main()
{
srand(time(NULL));
vector<int> a = { 1,2,12,12,1,2 };
show(a);
cout << endl;
system("pause>null");
}
1>C:\Users\Nikita\source\repos\LearnC++\LearnC++\Source.cpp(12,15): warning C4244: аргумент: преобразование "time_t" в "unsigned int", возможна потеря данных 1>Source.obj : error LNK2019: ссылка на неразрешенный внешний символ "void __cdecl show<class std::vector<int,class std::allocator > >(class std::vector<int,class std::allocator >)" (??$show@V?$vector@HV?$allocator@H@std@@@std@@@@YAXV?$vector@HV?$allocator@H@std@@@std@@@Z) в функции main. 1>C:\Users\Nikita\source\repos\LearnC++\x64\Debug\LearnC++.exe : fatal error LNK1120: неразрешенных внешних элементов: 1