質問編集履歴
2
質問文を修正致しました。失礼いたしました。
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
###前提・実現したいこと
|
2
|
-
引数つきのコンストラクタを追加したところエラーが起きま
|
2
|
+
引数つきのコンストラクタを追加したところエラーが起き、原因が分かりません。
|
3
|
+
すいません、勉強して一週間もたっていなくて、質問が投げやりな感じになってしまって申し訳ありませんが、回答お願い致します。
|
3
4
|
|
4
5
|
|
5
6
|
###発生している問題・エラーメッセージ
|
1
メイン文、ヘッダー文、エラー文を一部修正しました。
title
CHANGED
File without changes
|
body
CHANGED
@@ -9,6 +9,11 @@
|
|
9
9
|
/usr/include/string.h:129:14: note: candidate function not viable: no known conversion from 'char' to 'const char *restrict' for 2nd argument; remove *
|
10
10
|
extern char *strcpy (char *__restrict __dest, const char *__restrict __src)
|
11
11
|
^
|
12
|
+
Phone.cpp:37:21: warning: ISO C++11 does not allow conversion from string literal to 'char *' [-Wwritable-strings]
|
13
|
+
Phone p2(false, "p2","noraml");
|
14
|
+
^
|
15
|
+
1 warning and 1 error generated.
|
16
|
+
^
|
12
17
|
1 error generated.
|
13
18
|
###ソースコード
|
14
19
|
```
|
@@ -27,9 +32,10 @@
|
|
27
32
|
this->pInfo = "nokia";
|
28
33
|
}
|
29
34
|
|
30
|
-
Phone::Phone(bool i, char* plan){
|
35
|
+
Phone::Phone(bool i, char* plan, string pInfo){
|
31
36
|
this->i = i;
|
32
37
|
strcpy(this->plan,*plan);
|
38
|
+
this->pInfo = "nokia";
|
33
39
|
}
|
34
40
|
|
35
41
|
|
@@ -48,7 +54,7 @@
|
|
48
54
|
int main(){
|
49
55
|
cout << " main " <<"\n";
|
50
56
|
Phone p1;
|
51
|
-
|
57
|
+
Phone p2(false, "p2","noraml");
|
52
58
|
p1.i = false;
|
53
59
|
strcpy(p1.plan,"normal");
|
54
60
|
p1.pInfo = "nokia";
|
@@ -56,13 +62,14 @@
|
|
56
62
|
|
57
63
|
return 0;
|
58
64
|
}
|
65
|
+
|
59
66
|
<ヘッダー文>
|
60
67
|
#include <string.h>
|
61
68
|
|
62
69
|
class Phone{
|
63
70
|
public:
|
64
71
|
Phone();
|
65
|
-
Phone(bool i, char* plan);
|
72
|
+
Phone(bool i, char* plan, std::string pInfo);
|
66
73
|
~Phone();
|
67
74
|
bool i;
|
68
75
|
char* plan;
|