When any railroad company owning, leasing or operating a railroad in or through any part of this State shall have its terminus or any part of its track at or near the terminus of any other railroad in this State having the same gauge or shall cross such other railroad’s track, such railroad company may join its track by safe and proper switches, with such other railroad and for this purpose may enter upon the right of way of such other railroad. But if the railroad with which such connection is proposed shall refuse to join in paying the expenses of making such connection the railroad proposing the connection shall pay them.