Dempster-Shafer theory is widely applied in uncertainty modelling and knowledge reasoning due to its ability of expressing uncertain information. A distance between two basic probability assignments(BPAs) presents a measure of performance for identification algorithms based on the evidential theory of Dempster-Shafer. However, some conditions lead to limitations in practical application for Dempster-Shafer theory, such as exclusiveness hypothesis and completeness constraint. To overcome these shortcomings, a novel theory called D numbers theory is proposed. A distance function of D numbers is proposed to measure the distance between two D numbers. The distance function of D numbers is an generalization of distance between two BPAs, which inherits the advantage of Dempster-Shafer theory and strengthens the capability of uncertainty modeling. An illustrative case is provided to demonstrate the effectiveness of the proposed function.