写代码

最近写代码不在状态,或者说从一开始就很少在状态。

首先码字准确不够,经常打错;

第二,打的不够快,尤其在符号上,比如 [  ] ( ) 0 ; \  / <> “”等

第三,心里想的,和手上打出来的不一致。

 

不知道是IDE不够智能,还是过于智能,但它不符合我的心意。

 

 

对代码无论从结构上、功能上一定要先组织好再动手 ,尽可能的一遍成功。

成员函数声明和实现分开,分别在h和cpp文件中

注意循环声明的情况,比如:

 

// code inside 'common.h'
class NIMBoard
{
private:
DLList<NIMBoard> m_Children; // line 22 (common.h)
....
....
};


// code inside 'dllist.h'
template<class T>
class DLList
{
private:
// Node class
class Node
{
public:
T Data; // line 21 (dllist.h)
....
....
};
....
....
};

 

 

再比如:

 

#include "stdafx.h"

class B;
class A
{
public:
	B b;  //..Giving error here
	A()
	{
		printf("\nA()");
	}
	void print()
	{
		b.print();
		printf("\nPrint in A");
	}
	~A()
	{
		delete b;
		printf("\n~A()");
	}
};
class B
{
public:
	B()
	{
		printf("\nB()");
	}
	
	void print()
	{
		printf("\nPrint in B");
	}
	~B()
	{
		printf("\n~B()");
	}
	
};

int _tmain(int argc, _TCHAR* argv[])
{
	A a;
	a.print();
	return 0;
}
 
两个例子都是有问题的。

转载于:https://www.cnblogs.com/justin_s/archive/2011/01/12/1933949.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值