05_0824_编写String的问题(C++)
来源:互联网 发布:javascript权威指南 7 编辑:程序博客网 时间:2024/05/17 00:00
主函数如下:
#include "stdafx.h"
#include "iostream.h"
#include "String.h"
void main()
{
String str;
str='a';
★ cout<<str<<endl;
}
String类的定义如下:
class String
{
public:
String();
virtual ~String();
public:
String& operator=(char chVar);
protected:
char* m_pszBuffer;
int m_nLength;
};
String类的实现如下:
#include "stdafx.h"
#include "String.h"
String::String()
{}
String &String::operator = (char chVar)
{
m_pszBuffer=new char[2];
m_pszBuffer[0]=chVar;
m_pszBuffer[1]='/0';
return *this;
}
String::~String()
{}
程序编译出现如下问题:
error C2679: binary '<<' : no operator defined which takes a right-hand operand of type 'class String' (or there is no acceptable conversion)
Error executing cl.exe.
指向带有★的行。
- 05_0824_编写String的问题(C++)
- 教你编写STL的string类-01(理解C/C++内存管理)
- 教你编写STL的string类-02(理解C/C++内存管理)
- c++头文件的编写
- 用C编写一个自己的string库文件_01
- 在VS2010下编写C应注意的问题(和编写C++的区别)
- C++问题---sizeof(string)问题
- String的编写
- String类的编写
- string类的编写
- [C++]string中文的匹配问题
- C#string 的引用类型问题
- c#string注意问题
- C++string读入问题
- 自己编写的string库函数
- C#中如何调用C++编写的DLL
- C#中如何调用C++编写的DLL
- 编写可移植的C++程序
- JDK的命令详解
- 资源文件的编码问题
- J2EE
- J2EE(2)
- ASP.NET与JavaScript联合操作之一 选择DataGrid中的CheckBox控件后该行背景变色
- 05_0824_编写String的问题(C++)
- 审计算法
- 一个application含有多个显示在任务兰的form的问题
- 知名专家学者云集上海,C++社区历史性盛会
- 软件设计方案
- 在线跪求解答
- Tomcat中JDBCRealm的配置
- www
- log4j 学习系列