• 카테고리

    질문 & 답변
  • 세부 분야

    프로그래밍 언어

  • 해결 여부

    미해결

자꾸 오류가 뜨네요ㅜㅜ

21.10.04 19:15 작성 조회수 669

1

#include <iostream>

 

using namespace std;

 

class Stock

{

private:

string name;

int shares;

float share_val;

double total_val;

void set_total() { total_val = shares * share_val; }

 

public:

void acquire(string&, int, float);

void buy(int, float);

void sell(int, float);

void updata(float);

void show();

Stock();

~Stock();

};

void Stock::acquire(string& co, int n, float pr)

{

name = co;

shares = n;

share_val = pr;

set_total();

 }

 

void Stock::buy(int n, float pr)

{

shares += n;

share_val = pr;

set_total();

}

 

void Stock::updata(float pr)

{

share_val = pr;

set_total();

}

 

void Stock::show()

{

cout << "회사 명 : " << name << endl;

cout << "주식 수 : " << shares << endl;

cout << "주가 : " << share_val << endl;

cout << "주식 총 가치 : " << total_val << endl;

}

 

Stock::Stock()

{

 

}

Stock::~Stock()

{

 

}

int main()

{

Stock temp;

temp.acquire("",100, 1000);

temp.show();

temp.buy(10, 1200);

temp.show();

temp.sell(5, 800);

temp.show();

 

return 0;

}

심각도 코드 설명 프로젝트 파일 비표시 오류(Suppression) 상태

오류(활성) E0434 "std::string &" 형식(const 한정 형식 아님)의 참조를 "const char [1]" 형식의 값으로 초기화할 수 없습니다. 1 C:\Users\user\source\repos\1\1\main.cpp 63

디버깅이 않 되요ㅠㅠ

 

 

답변 1

답변을 작성해보세요.

0

혹시 acquire의 참조연산자를 제거해보시겠어요?