DEV-C++中 [Linker error] undefined reference to `void consumme(buffer& std:string, std:string&)'解决方案
DEV-C++中 [Linker error] undefined reference to `void consumme<std::string>(buffer<std::string>&, std::string, std::string&)'
我用的DEV-C++ 4.9.2
-----------------------------main.cpp------------------------------
#include <cstdlib>
#include <iostream>
#include <string>
#include "buffer.h "
using std::cout;
using std::endl;
using std::string;
template <class T>
void consumme(buffer <T> &destination, string dest_name, T &fetched_product);
int main(void)
{
buffer <string> share_buf(20);
string fetched_product;
consumme(share_buf, "share_buf ", fetched_product);
system( "PAUSE ");
return EXIT_SUCCESS;
}
---------------------------consummer.cpp--------------------------------
#include "buffer.h "
#include <iostream>
#include <string>
using std::cout;
using std::endl;
using std::string;
template <class T>
void consumme(buffer <T> & destination, string dest_name, T &fetched_product)
{
int print1 = 0;
int print2 = 0;
while(destination.buf_is_empty())
{
if (print1 == 0)
{
print1 = 1;
cout < < "the " < < dest_name < < " is empty, so the consummer must wait... " < < endl;
}
}
while(destination.buf_is_locked())
{
if (print2 == 0)
{
print2 = 1;
cout < < "the " < < dest_name < < " is unaccessiable now, so the producer must wait... " < < endl;
}
}
destination.lock_buf();
if(destination.fetch_data(fetched_product));
我用的DEV-C++ 4.9.2
-----------------------------main.cpp------------------------------
#include <cstdlib>
#include <iostream>
#include <string>
#include "buffer.h "
using std::cout;
using std::endl;
using std::string;
template <class T>
void consumme(buffer <T> &destination, string dest_name, T &fetched_product);
int main(void)
{
buffer <string> share_buf(20);
string fetched_product;
consumme(share_buf, "share_buf ", fetched_product);
system( "PAUSE ");
return EXIT_SUCCESS;
}
---------------------------consummer.cpp--------------------------------
#include "buffer.h "
#include <iostream>
#include <string>
using std::cout;
using std::endl;
using std::string;
template <class T>
void consumme(buffer <T> & destination, string dest_name, T &fetched_product)
{
int print1 = 0;
int print2 = 0;
while(destination.buf_is_empty())
{
if (print1 == 0)
{
print1 = 1;
cout < < "the " < < dest_name < < " is empty, so the consummer must wait... " < < endl;
}
}
while(destination.buf_is_locked())
{
if (print2 == 0)
{
print2 = 1;
cout < < "the " < < dest_name < < " is unaccessiable now, so the producer must wait... " < < endl;
}
}
destination.lock_buf();
if(destination.fetch_data(fetched_product));