随笔分类 -  c++

c++
摘要:类中的静态成员真是个让人爱恨交加的特性。我决定好好总结一下静态类成员的知识点,以便自己在以后面试中,在此类问题上不在被动。 静态类成员包括静态数据成员和静态函数成员两部分。 一 静态数据成员: 类体中的数据成员的声明前加上static关键字,该数据成员就成为了该类的静态数据成员。和其他数据成员一样,静态数据成员也遵守public/protected/private访问规则。同时,静态数据成员还具有以下特点: 1.静态数据成员的定义。 静态数据成员实际上是类域中的全局变量。所以,静态数据成员的定义(初始化)不应该被放在头文件中。 其定义方式与全局变量相同。举例如下: xxx.h文件 class 阅读全文
posted @ 2013-11-22 10:32 forgood 阅读(189) 评论(0) 推荐(0)
摘要:#include int main(int argc, char **argv){ const int* pA = new int(3); int& iB = const_cast(*pA); //pA的值可以改变 int* pC = const_cast(pA); iB = 5; *pC = 6; std::cout (iA);//另外申请一块空间,副本 pC = const_cast(&iA); iB = 987; *pC = 999; std::cout << "a=" << iA << std::endl; std 阅读全文
posted @ 2013-11-03 18:45 forgood 阅读(172) 评论(0) 推荐(0)
摘要:1 class CObject 2 { 3 friend class CPlyLoader; 4 public: 5 CObject::CObject() : m_pMaterial(NULL) {} 6 CObject::~CObject() 7 { 8 m_Vertex.clear(); 9 m_VertexNormal.clear();10 m_FacetIndices.clear();11 m_FacetNo... 阅读全文
posted @ 2013-11-03 18:29 forgood 阅读(271) 评论(0) 推荐(0)
摘要:#include namespace Virtual{ class CBase { public: CBase() {} virtual ~CBase() {} void testBase() { print(); } virtual void print() = 0; }; class CDived : public CBase { public: CDived() {} ~CDived() {} void testDived() {testBase();} void print() {std::cout << "CDived's print() is... 阅读全文
posted @ 2013-11-03 09:25 forgood 阅读(179) 评论(0) 推荐(0)
摘要:1 #pragma once 2 3 #include 4 5 namespace WYP 6 { 7 class CBase 8 { 9 public:10 int m_BasePublic;11 12 void setY(int y) {m_y = y;}13 void setZ(int z) {m_z = z;}14 int getX() {return m_x;}15 int getZ() {return m_z;}16 17 protected:18 ... 阅读全文
posted @ 2013-10-31 23:46 forgood 阅读(277) 评论(0) 推荐(0)
摘要:#pragma once#include #include #include namespace WYP{ class CBase { public: CBase() : m_BaseX(0), m_ptr(NULL) {std::cout setPtr(pInt); std::cout getInt() setMemberX(3); std::cout getMemberX() bulid(123); pBase->print(); std::cout << "xxxx\n" << "\n" ; delete pBase; 阅读全文
posted @ 2013-10-31 23:07 forgood 阅读(171) 评论(0) 推荐(0)
摘要:不止一次的被网友问到如何为自己的程序加皮肤了,第一次花了不少时间,给网友讲明白了。哈哈不过今天又来了,实在没有这么多精力来一次次的讲,于是写了下面的文章来详细的说明如何使用SSK格式的皮肤【文件清单】skinplusplus.hskinplusplusdll.dllskinplusplusdll.libxpcorona.ssk方法一首先我们把上面的所有文件都与程序的源文件放到同一目录。这样做的目的是,方便引用,不须要太多的项目配置。现在在程序的主进程引入#include "skinplusplus.h",然后,在BOOL CXXApp::InitInstance(){}里面 阅读全文
posted @ 2013-04-08 09:53 forgood 阅读(1037) 评论(0) 推荐(1)
摘要:Problem Descriptionhttp://acm.hdu.edu.cn/showproblem.php?pid=1072Ignatius had a nightmare last night. He found himself in a labyrinth with a time bomb on him. The labyrinth has an exit, Ignatius should get out of the labyrinth before the bomb explodes. The initial exploding time of the bomb is set t 阅读全文
posted @ 2012-04-17 00:53 forgood 阅读(174) 评论(0) 推荐(0)