解決:重新啓動的Visual Studio的Visual Studio 2010的列表複製構造拋出C2664錯誤
我工作的一個項目,涉及STL
列表學校。並與xmemory
得到此錯誤。我只是試圖建立在這一點上的解決方案,但xmemory
死我
錯誤1錯誤C2664: 'GroceryStoreItem :: GroceryStoreItem(GroceryStoreItem &)':無法從「的std :: string轉換參數1 '到 'GroceryStoreItem &' d:\微軟的Visual Studio 10.0 \ VC \包括\ xmemory 208
這裏是我的頭
#include <string>
#include <sstream>
#include<iostream>
#include <iterator>
#include <list>
using namespace std;
//
//*****************************************************************
// USER DEFINED DATA TYPES
//
class GroceryStoreItem
{
friend ostream & operator<< (ostream &out, const GroceryStoreItem &RHS);
public:
GroceryStoreItem();
GroceryStoreItem(string Name, double cost, string location);
GroceryStoreItem(GroceryStoreItem & GroceryStoreItemCCIn);
GroceryStoreItem & operator= (const GroceryStoreItem &RHS);
string ReturnItemName();
string ReturnLocation();
double ReturnCost();
private:
string ItemName;
string Location;
double Cost;
};
和實施
#include "Grocery_Item.h"
using namespace std;
//*****************************************************************
// Grocery Item Constructors
//*****************************************************************
GroceryStoreItem::GroceryStoreItem()
{
ItemName = "default";
Location = "aisle 1";
Cost = 0.0;
}
GroceryStoreItem::GroceryStoreItem(string InName, double InCost, string InLocation)
{
ItemName = InName;
Location = InLocation;
if(InCost >= 0.0f)
{
Cost = InCost;
}
else
{
Cost = 0.0f;
}
}
GroceryStoreItem::GroceryStoreItem(GroceryStoreItem & GroceryStoreItemCCIn) //Copy Constructor
{
ItemName=GroceryStoreItemCCIn.ItemName;
Location=GroceryStoreItemCCIn.Location;
Cost=GroceryStoreItemCCIn.Cost;
}
編輯 xmemory
錯誤的
template<class _Other>
void construct(pointer _Ptr, _Other&& _Val)
{ // construct object at _Ptr with value _Val
::new ((void _FARQ *)_Ptr) _Ty(_STD forward<_Other>(_Val));
此錯誤來自哪條線?發佈代碼的那一部分。 – 2013-05-04 05:40:23