#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
에 저장해야합니다. 당신의 멤버 함수
각 사례 블록의 끝에 '중단'을 추가하십시오. 그렇지 않으면 넘어지게됩니다. –
@AdrianPanasiuk thanx, 나는 모든 코딩을 마친 후에 그들을 추가 할 예정이었습니다. –
즉, optionChosen == 1 일 때 먼저'case 1 :'블록의 코드가 실행되고'case 2 :'의 코드가 실행됩니다. (당신은 break를 가지지 않기 때문에 다음 case 블록을 실행하지 않는다는 것을 의미합니다) –