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

帮忙解决问题

晓宁 发布于 2011-09-12 17:23, 299 次点击
#include<iostream>
using namespace std;

class Var
{
    char word[10];
    int num1;
    double num2;

public:

    void setdata(int i)
    {
        num1=i;
    }
    void setdata(double f)
    {
        num2=f;
    }

    void setdata(char *c)
    {
        strcpy(word,c);
    }

    void showdata()
    {
        cout<<" Here is int "<<num1<<endl;
        cout<<" Here is float "<<num2<<endl;
        cout<<" Here is char* "<<word<<endl;
    }
};

void main()
{
    Var a;
    a.setdata(10);
    a.setdata(10.10);
    a.setdata("ten");
    a.showdata();
}


strcpy(word,c); //undeclared identifier这是什么问题?



[ 本帖最后由 晓宁 于 2011-9-12 17:30 编辑 ]
4 回复
#2
城东古桥2011-09-12 18:16
没有包含头文件或者没有声明该函数
#3
晓宁2011-09-12 18:50
以下是引用城东古桥在2011-9-12 18:16:23的发言:

没有包含头文件或者没有声明该函数
可以帮忙吗?
#4
czsbc2011-09-12 18:57
#include<string.h>
#5
晓宁2011-09-12 19:33
谢谢
1