C/C++
geektao
奋斗着的程序猿
展开
-
vc++6.0 类中定义 static 变量报错
在实验《提高C++性能的编程技术》中第一个源代码是遇到了报错。。。。。自己补全了点代码:#pragma once#include #include using namespace std;class Trace{public: Trace(const string &name); ~Trace(); void debug(const string &msg);原创 2012-03-26 15:20:01 · 1812 阅读 · 0 评论 -
C++静态成员变量详谈
C++静态成员变量是用static修饰的成员变量,不属于对象的一部分,而是类测一部分,因此可以在没有实例化任何对象的时候使用静态成员变量。但是必须初始化它。 由于静态变量只能被初始化一次,所以初始化成员变量不要放在如下地方:1.类的构造函数(构造函数可能多次被调用);2.头文件中(头文件可能被包含入多个地方,也可能被执行多次)。应该放在应用程序中,类以外的任何地方初始化,例如:在原创 2012-05-03 09:34:47 · 16662 阅读 · 1 评论 -
error C2679: binary '>>'
今天在学习C++读写文件时,照着书上的代码打了一遍。结果呢,编译出错了。错误如下:error C2679: binary '>>' : no operator defined which takes a right-hand operand of type 'class std::basic_string,class std::allocator >' (or there is no acce原创 2012-09-24 14:59:19 · 16547 阅读 · 4 评论