• 写代码


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

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

    第二,打的不够快,尤其在符号上,比如 [  ] ( ) 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;
    }
     
    两个例子都是有问题的。
  • 相关阅读:
    ABP
    妖道角
    检测空值,以及会不会出现mapping类型不一致的问题
    wcf服务契约代理链
    wcf服务契约继承
    win64+anaconda+xgboost(转)
    python中迭代问题
    ROC曲线和AUC值(转)
    python中split()和split(' ')的区别
    str和repr的区别(转)
  • 原文地址:https://www.cnblogs.com/justin_s/p/1933949.html
Copyright © 2020-2023  润新知