#include <iostream>
using namespace std;
string itmCndtn,itemName;
int strtPrice,sellValue,numRelist,optn=0;
class CBAY_ITEM
{
string enterName();
string enterCondition();
int enterStrtPrc();
int enterSellVal();
};
CBAY_ITEM infoClass;
CBAY_ITEM *nPointer=NULL;
int main()
{
int optionChosen=0;
int strtPrcTemp=0,sellValueTemp=0;
do
{
cout << "\nPlease Enter a Choice From the Menu.\n"<<endl;
cout << "\n1.Add an Item to Selling Queue.\n2.Put Item for Sale.\n3.Show Me the Money.\n4.Exit." << endl;
cin>>optionChosen;
switch(optionChosen)
{
case 1:
{
nPointer=new CBAY_ITEM;
nPointer->enterName()=infoClass.enterName();
nPointer->enterCondition()=infoClass.enterCondition();
nPointer->enterStrtPrc()=infoClass.enterStrtPrc();
nPointer->enterSellVal()=infoClass.enterSellVal();
}
case 2:
{
}
case 3:
{
}
}
}while(optionChosen!=4);
return 0;
}
到目前为止,这是我的代码,我省略了类中函数的定义,因为它似乎不是问题所在。当我尝试编译时,编译器显示错误消息
lvalue required as left operand of assignment.
我不确定它想说什么。
nPointer->enterStrtPrc()=infoClass.enterStrtPrc();
nPointer->enterSellVal()=infoClass.enterSellVal();
应该返回 int 值并将它们存储在动态创建的类infoClass
中。