该程序应该在课堂上展示建设性和破坏性功能的功能

this program is supposed to show the function of constructive and destructive function in class

本文关键字:性功能 功能 建设性 程序 课堂      更新时间:2023-10-16

不幸的是,我收到了此错误:没有与参数列表匹配的重载函数strcpy_s实例。我不知道这是什么剂量?? 你介意帮帮我吗?

//......................................................
#include<iostream>
#include<conio.h>
using namespace std;
class one
{
    char *s;
public:
    one()
    {
        cout << "constructiven";
    }
    void f(char *str)
    {
        s = new char[strlen(str) + 1];
        strcpy_s(s, str);
    }
    void f1()
    {
        cout << s << "n";
    }
    ~one()
    {
        cout << "destructive";
    }
};
one f2()
{
    char s[80];
    one x;
    cout << "enter a string: n";
    gets_s(s);
    x.f(s);
    return x;
}
int main()
{
    one a;
    a = f2();
    a.f1();
    _getch();
    return 0;
}
//................................................

这意味着编译器找不到该函数,那是因为您没有#include <cstring> .