已解决:重新启动 Visual Studio
我正在为学校开展一个涉及该STL
列表的项目。并使用xmemory
. 我只是想在这一点上构建解决方案,但xmemory
正在杀了我
错误 1 错误 C2664:“GroceryStoreItem::GroceryStoreItem(GroceryStoreItem &)”:无法将参数 1 从“std::string”转换为“GroceryStoreItem &”d:\microsoft visual studio 10.0\vc\include\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));