| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1444 人关注过本帖
标题:新手求教
只看楼主 加入收藏
菲若
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2018-9-18
结帖率:0
收藏
 问题点数:0 回复次数:3 
新手求教
#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)

搜索更多相关主题的帖子: char Name point strcpy cout 
2018-09-18 08:39
Jonny0201
Rank: 11Rank: 11Rank: 11Rank: 11
等 级:贵宾
威 望:52
帖 子:488
专家分:2603
注 册:2016-11-7
收藏
得分:0 
#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();
}
2018-09-18 08:50
菲若
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2018-9-18
收藏
得分:0 
回复 2楼 Jonny0201
谢谢! 但是我可以问一下 为什么我之前那样不可以吗
2018-09-18 13:30
Jonny0201
Rank: 11Rank: 11Rank: 11Rank: 11
等 级:贵宾
威 望:52
帖 子:488
专家分:2603
注 册:2016-11-7
收藏
得分:0 
回复 3楼 菲若
你应该认真读一下编译错误
2018-09-18 20:17
快速回复:新手求教
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.033422 second(s), 10 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved