1.VS2010 编译项目的时候在first.cpp中报Error C2665,
2.在网上搜索了问题,似乎大部分都指向,我使用了std::vector 作为函数模板
first.cpp
template class Blocks<interface::Ring>;
template class Blocks<interface::Cube>;
template <typename BookType>
bool Blocks<BookType>::update(const BookType &NewBook){
std::vector<std::pair<Time, BookType>> BookPair;
std::vector<BookType> NewBookContainer;
BookPair.push_back(std::make_pair(_SizeThreshold,NewBook));
if(typeid(NewBook)!=typeid(interface::Ring)&&typeid(NewBook)!=typeid(interface::Cube)){
for(auto Iter = BookPair.begin(); Iter->first < _SizeThreshold; ++Iter){
NewBookContainer.push_back(Iter->second);
BookPair.erase(Iter);
}
_result = li::ki::UpdateBooK(NewBookContainer);// where error reported
}
return true;
}
second.cpp
namespace li{
ki{
interface::Ring UpdateBooK(std::vector<interface::Ring>& NewBookContainer) {
interface::Ring result = NewBookContainer.back();
interface::BookPrice TempPrice;
interface::BookColor TempColorX;
interface::BookColor TempColorY;
int count = 0;
for (auto Iter = NewBookContainer.begin(); Iter != NewBookContainer.end(); ++Iter)
{
TempPrice = convertePoi(TempPrice, count, Iter->getPrice(), 1);
TempColorX = converteColor(TempColorX, count, Iter->getColorY(), 1);
TempColorY = converteColor(TempColorY, count, Iter->getColorX(), 1);
count++;
}
result.setPrice(TempPrice);
result.setColorY(TempColorX);
result.setColorX(TempColorY);
return result;
}
interface.h
class Ring:public Base {
public:
Ring();
explicit Ring(const ColorBase& clm);
explicit Ring(
const BookPrice& Price,/*class BookPrice{public:BookPrice(const Element& price = Element())};*/ /*struct Element {double x;double y;};*/
const BookColor& ColorX,
const BookColor& ColorY);
const BookPrice& getPrice() const;
void setPrice(const BookPrice& Price);
const BookColor& getColorX() const;
void setColorX(const BookColor& ColorX);
const BookColor& getColorY() const;
void setColorY(const BookColor& ColorY);
};
}