
c++基础
文章平均质量分 75
abc78400123
学生而已
展开
-
VC6.0中友元函数无法访问类私有成员的解决办法-------VC6.0的bug
举个例子: #includeusing namespace std;class cylinder{ friend istream operator>>(istream& is,cylinder &cy);public: inline double square() { return length*(width+height)*2+width转载 2012-05-22 20:15:04 · 1130 阅读 · 0 评论 -
类成员函数作为其他类的友元函数的实现(c++语言)
关于类成员函数作为友元函数的编写方法(1) 单文件编译#include using std::cout;class One; //Another中使用One的引用,故前向引用声明class Another{private:int n;public:Another(): n(2){}转载 2012-05-23 21:16:12 · 1440 阅读 · 0 评论 -
前向引用声明
前向引用声明 2008-04-16 16:04:20类间的交叉引用的情况, 需要前向引用声明. 前向引用声明不能声明该类的对象, 也不能在内联成员函数中使用该类的对象, 只能声明该类的指针, 引用, 函数形参和返回类型.// Right.h /////////////////////////////////////////// no #include "L转载 2012-05-24 19:21:25 · 1929 阅读 · 0 评论 -
C++中类的声明
可以声明一个类而不定义它 class Screen;//declaration of the Screen class 这个声明,有时候被称为前向声明(forward declaration),在程序中引入了类类型的Screen.在声明之后,定义之前,类Screen是一个不完全类型(incompete type),即已知Screen是一个类型,但不知道包含哪些成员. 不完全转载 2012-05-24 18:00:57 · 31786 阅读 · 1 评论 -
一个简单的c++程序
#include using namespace std;class vehicle{protected:int wheels;int weight;public:virtual void display(){cout<<wheels<<weight<<endl;}vehicle(){wheels = 1;weight = 2;}~vehicle(){cout<<"释放12";原创 2012-05-20 15:24:13 · 574 阅读 · 0 评论