我不明白爲什麼我的編譯器給我一個關於從字符串到char的棄用轉換的警告。C++ - 棄用從字符串常量轉換爲字符
這是在抱怨警告:
只是有點我在做什麼..我試圖理解和實踐例外背景的......我不知道,如果它能夠更好只是與char [1000]的名字等工作..我會非常感謝,如果有人幫助理解警告,並幫助我找到解決方案..謝謝..
====== ================================================== =========================
class TeLoEnYuco
{
string FN, LN, R;
double Income;
public:
const char *getters(){return FN.data(), LN.data(), R.data();}
virtual char *getFacilityAccess()=0;
TeLoEnYuco(char *fn, char *ln, char r, double inc)
{
if(fn==0) throw Exception(1, "First Name is Null"); //Warning #1
if(ln==0) throw Exception(2, "Last Name is Null"); //Warning #2
if(r==0) throw Exception(3, "Rank is Null"); //Warning #3
if(inc<=0) throw Exception(4, "Income is Null"); //Warning #4
FN=fn;
LN=ln;
R=r;
Income=inc;
}
};
=====================異常類========================== =======
class Exception
{
int Code;
string Mess;
public:
Exception(int cd, char *mess)
{
Code=cd;
Mess=mess;
}
int getCode(){return Code;}
const char *getMess(){return Mess.data();}
};
哪條線是錯誤的?什麼是實際的錯誤信息? –
如何定義'Exception'? –
'getters'返回3個值? –