注册 登录
编程论坛 C++教室

新手求教

菲若 发布于 2018-09-18 08:39, 1618 次点击
#include<iostream.h>
#include<string.h>
class Cmenu
{
public:
    char Name[20];
    char Food[100];
    char Process[200];
    char setpoint(char *x)
    {strcpy(point,x);}
    char getpoint()
    {cout<<point;}
private:
    char point[200];
};
void main()
{
    Cmenu Yu;
      strcpy(Yu.Name,"YuxiangShreddedPork");
      strcpy(Yu.Food,"pork agaric carrot some batching");
      strcpy(Yu.Process,"firstly,you have to make the pork quick-fired.then putting batching into pot.besides,it is time to put agaric and carrot.finally,waitting for minutes to a mature dish");
      strcpy(Yu.setpoint,"the time of this dish should be controlled in fifteen-minutes.what is more important is thicken soup which usually mixes light soy sauce,amylum,albumen and water.");
      cout<<"Name:"<<Yu.Name<<"\n";
      cout<<"Food:"<<Yu.Food<<"\n";
      cout<<"Process:"<<Yu.Process<<"\n";
      cout<<"point:"<<Yu.getpoint();
}



以下是错误
:\Users\Lenovo\Desktop\zmx.cpp(22) : error C2664: 'strcpy' : cannot convert parameter 1 from 'char (char *)' to 'char *'
        There is no context in which this conversion is possible
执行 cl.exe 时出错.

zmx.obj - 1 error(s), 0 warning(s)

3 回复
#2
Jonny02012018-09-18 08:50
#include <iostream>
using namespace std;
class Cmenu
{
public:
        char Name[20];
        char Food[100];
        char Process[200];
        void setpoint(const char *x)
        {strcpy(point,x);}
        void getpoint()
        {cout<<point;}
private:
        char point[200];
};
int main()
{
        Cmenu Yu;
            strcpy(Yu.Name,"YuxiangShreddedPork");
            strcpy(Yu.Food,"pork agaric carrot some batching");
            strcpy(Yu.Process,"firstly,you have to make the pork quick-fired.then putting batching into pot.besides,it is time to put agaric and carrot.finally,waitting for minutes to a mature dish");
            Yu.setpoint("the time of this dish should be controlled in fifteen-minutes.what is more important is thicken soup which usually mixes light soy sauce,amylum,albumen and water.");
            cout<<"Name:"<<Yu.Name<<"\n";
            cout<<"Food:"<<Yu.Food<<"\n";
            cout<<"Process:"<<Yu.Process<<"\n";
             Yu.getpoint();
}
#3
菲若2018-09-18 13:30
回复 2楼 Jonny0201
谢谢! 但是我可以问一下 为什么我之前那样不可以吗
#4
Jonny02012018-09-18 20:17
回复 3楼 菲若
你应该认真读一下编译错误
1