程序老有问题,求大神解答,求助,急
这是我的程序使用运算符重载,实现两字符相加
#include<str.h>
const int MAXSIZE=100;
class String
{
private:
char buffer[MAXSIZE];
int len;
public:
String(char s_str);
String operator+(char c_str);
void print();
};
#include<iostream>
using namespace std;
#include<string.h>
int main()
{
String s1("C/C++");
s1=s1.operator+("program"); //这个程序有问题
s1.print();
}
String::String(char s_str)
{
strcpy(buffer,s_str);
len=strlen(bufffer);
}
String String::operator+(char c_str)
{
String add;
add.len=strlen(buffer)+strlen(c_str)+1;
if(add.len>MAXSIZE)
{
cout<<"超出范围"<<endl;
strcpy(add.buffer,buffer);
add.len=strlen(buffer);
}
else
{
strcpy(add.buffer,buffer);
strcat(add.buffer,c_str);
return add;
}
void String print()
{
cout<<"相加后的字符串为;"<<endl;
cout<<buffer<<endl;
cout<<"字符串长度为;"<<endl;
cout<<len<<endl;
}
编译之后老有问题;
fatal error: str.h: No such file or directory
哪位大哥知道请告诉一下,谢谢了