strcpy関数でのエラーについて
Posted: 2010年10月31日(日) 22:17
いつもお世話になっております。
さっそくですみませんが、標準関数のstrcpyを用いた多重継承のサンプルを実行したら、
以下のようなエラーメッセージが出ました。いちおう実行結果にも問題なく実行できましたが、
今後のことも考えて質問させていただきました。
どうかよろしくお願いしますm(_ _)m
【環境】Visual C++ 2008 Express Edition
========================================================================================
エラーメッセージ
========================================================================================
warning C4996: 'strcpy': This function or variable may be unsafe.
Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS.
See online help for details.
'strcpy' の宣言を確認してください。
========================================================================================
このようなメッセージがstrcpyの数だけ出ました。
========================================================================================
プログラム
========================================================================================
#include <iostream>
#include <string.h>
using namespace std;
class A
{
protected:
char str[64];
public:
A();
};
class B
{
protected:
char str[64];
public:
B();
};
class C : public A, public B
{
char str[64];
public:
C();
void show(void);
};
A::A()
{
strcpy(str, "classA\n");
}
B::B()
{
strcpy(str, "classB\n");
}
C::C()
{
strcpy(str, "classC\n");
}
void C::show()
{
cout << str;
cout << A::str;
cout << B::str;
return;
}
int main()
{
C test;
test.show();
return 0;
}
========================================================================================
preタグ、/preタグでプログラムを囲んだら、ものすごく空白と改行が増えました><
さっそくですみませんが、標準関数のstrcpyを用いた多重継承のサンプルを実行したら、
以下のようなエラーメッセージが出ました。いちおう実行結果にも問題なく実行できましたが、
今後のことも考えて質問させていただきました。
どうかよろしくお願いしますm(_ _)m
【環境】Visual C++ 2008 Express Edition
========================================================================================
エラーメッセージ
========================================================================================
warning C4996: 'strcpy': This function or variable may be unsafe.
Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS.
See online help for details.
'strcpy' の宣言を確認してください。
========================================================================================
このようなメッセージがstrcpyの数だけ出ました。
========================================================================================
プログラム
========================================================================================
#include <iostream>
#include <string.h>
using namespace std;
class A
{
protected:
char str[64];
public:
A();
};
class B
{
protected:
char str[64];
public:
B();
};
class C : public A, public B
{
char str[64];
public:
C();
void show(void);
};
A::A()
{
strcpy(str, "classA\n");
}
B::B()
{
strcpy(str, "classB\n");
}
C::C()
{
strcpy(str, "classC\n");
}
void C::show()
{
cout << str;
cout << A::str;
cout << B::str;
return;
}
int main()
{
C test;
test.show();
return 0;
}
========================================================================================
preタグ、/preタグでプログラムを囲んだら、ものすごく空白と改行が増えました><