| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 906 人关注过本帖
标题:报错。。。救~
取消只看楼主 加入收藏
zhao9302
Rank: 1
等 级:新手上路
帖 子:170
专家分:0
注 册:2007-5-10
收藏
 问题点数:0 回复次数:0 
报错。。。救~
#include<iostream>
#include<string>
using namespace std;
class Student;
class Teacher
{
public:
int num;
string name;
char sex;
string zhicheng;
Teacher(int n,string na,char s,string zc):num(n),name(na),sex(s),zhicheng(zc){}
void output(Student &);
};
class Student
{
public:
Student(int n,string na,char s,string zc):num(n),name(na),sex(s),zhiwu(zc){}
int num;
string name;
char sex;
string zhiwu;
Student(Teacher &t)
{
  num=t.num;
  strcpy(name,t.name);
  sex=t.sex;
}
friend void Teacher::output(Student &);
};
void Teacher::output(Student &s)
{
cout<<"Teacher:"<<endl;
cout<<"Num :"<<num<<endl;
cout<<"Name:"<<name<<endl;
cout<<"Post:"<<zhicheng<<endl;
cout<<"Student:"<<endl;
cout<<"Num :"<<s.num<<endl;
cout<<"Name:"<<s.name<<endl;
cout<<"Post:"<<s.zhiwu<<endl;
}
int main()
{
Teacher t(1001,"zhao",'M',"professor");
Student s(1002,"zhoa",'M',"NULL");
t.output(s);
return 0;
}

红色那句报错:

--------------------Configuration: Cpp1 - Win32 Debug--------------------
Compiling...
Cpp1.cpp
C:\Documents and Settings\Administrator\桌面\新建文件夹\Cpp1.cpp(28) : error C2664: 'strcpy' : cannot convert parameter 1 from 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' to 'char *'
        No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
执行 cl.exe 时出错.
Cpp1.exe - 1 error(s), 0 warning(s)

[[italic] 本帖最后由 zhao9302 于 2007-12-6 16:31 编辑 [/italic]]
搜索更多相关主题的帖子: public include zhiwu 
2007-12-06 13:31
快速回复:报错。。。救~
数据加载中...
 
   



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

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