This paper explores a model on cooperative cognitive radio network (CCRN) to enable the in-band bidirectional device-to-device (D2D) communications by sharing the licensed spectrum of cellular system (CS) in a 5G heterogeneous networks (HetNets) framework. In this model, cellular nodes (CNs) are modelled as primary users (PUs) and devices involved in D2D communications are referred as secondary users (SUs). The D2D pair, as unlicensed users, access to the licensed spectrum originally assigned to the CN pair while assuring relaying action to assist two-way communications between the CNs. Further, the D2D pair exploits the information-bearing radio frequency (RF) signals transmitted by the CNs to energize their transceivers, using the principle of simultaneous wireless information and power transfer (SWIPT). Closed form outage expressions of both cellular and D2D communications are derived. Simulation results are used to validate our analytical results. Simulation results show that about ~ 68% and ~ 277% gains are achieved by the proposed system in terms of spectrum efficiency and energy efficiency, respectively as compared to another prominent study on spectrum sharing enabled two-way PU and two-way SU communications.