Przedstawie kilka wersji tego samego kodu :
#include "Wczytywajka.hpp"
#include <string>
using namespace std;
template<typename T> void inputer(){}
template<typename T,typename... Rest> void inputer(const T& x, Rest... rest)
{
cout<<x<<endl;
inputer<T>(rest...);
}
int main()
{
inputer<string>("gg","gg");
return 0;
}
^ Dziala
#include "Wczytywajka.hpp"
#include <string>
using namespace std;
template<typename T> void inputer(){};
template<typename T,typename... Rest> void inputer(const T& x, Rest... rest)
{
cout<<x<<endl;
inputer<T>(rest...);
}
int main()
{
inputer<string>("gg","gg");
return 0;
}
^Dziala
#include "Wczytywajka.hpp"
#include <string>
using namespace std;
template<typename T> void inputer();
template<typename T,typename... Rest> void inputer(const T& x, Rest... rest)
{
cout<<x<<endl;
inputer<T>(rest...);
}
int main()
{
inputer<string>("gg","gg");
return 0;
}
^ Nie dziala.
Czy moglby mi ktos wytlumaczyc o co w tym chodzi.
Zapomnialem powyzej, Czesc!!!, dzieki za pomoc i pozdrawiam.
Te dziwne html'owe znaczniki dodaje to forum w poczatkowym zamysle mialo tam byc () ale sie psuje.
Dobra teraz wlasnie sprobowalem napisac ciutke inna funkcje niz powyzsze za pomoca parameter pack'a o to kod :
#include "Wczytywajka.hpp"
#include <string>
using namespace std;
template<typename T> void inputer(){}
template<typename T,typename... Rest> void inputer(const T& x, Rest... rest)
{
cin>>x;
inputer<T>(rest...);
}
int main()
{
int a,b;
inputer<int>(a,b);
return 0;
}
I pytanie jest takie gdy kompiluje dostaje tylko blad :Wczytywajka.cpp|| undefined reference to `void inputer<int, int>(int&, int)'| a codeblocks mi nawet nie podkresla w ktorej linii jest blad ktos wie o co chodzi i dlaczego kod sie nie kompiluje ?