c ++使用shared_ptr到未知大小的二维数组作为函数

时间:2017-04-27 08:42:38

标签: arrays c++11 shared-ptr

我试图在由瓷砖组成的地图上实施Dijkstras算法(即6x6 m的区域由40x40 cm的块组成,这些区域是可访问的或墙壁)并且要做到这一点我需要计算两个瓷砖之间的距离。 我创建了两个类TileDij_Tile,其中Tile class是包含位置等的实际/物理图块,Dij_Tile class包含一个shared_ptr Tile代表catch.hpp代表以及到达费用等。

我在我的测试文件中(使用all_tiles_test创建测试文件)一个包含所有切片(称为shared_ptr)的数组,这是一个包含所有切片的二维数组。

然后我为这个数组创建了一个指针(all_tiles_test_ptr)(名为all_tiles_test_ptr)。

之后,我想将 std::shared_ptr<Tile> all_tiles_test[2][2]; auto all_tiles_test_ptr(all_tiles_test); 发送给计算两个图块之间距离的函数。 问题是我不知道如何声明输入到函数的输入,其中输入是一个未知(编码时)大小的二维数组的shared_ptr。我该怎么做?

测试文件中的声明:

double tile_dist(std::shared_ptr<Dij_Tile> start_dij_tile_ptr,
     std::shared_ptr<Dij_Tile> end_dij_tile_ptr,
     std::shared_ptr<???> all_tiles_ptr);

该函数位于另一个文件(Tile_Distance .h和.cc)中:

function init(){
	var ele = px_all["ctl00_phF_tab_t0_edStatus"].getValue();
	document.getElementById("ctl00_phF_tab_t3_edTImeClock").style.fontSize = "49px";
	document.getElementById("ctl00_phF_tab_t3_edTImeClock").style.height = "50px";
	document.getElementById("ctl00_phF_tab_t3_edTImeClock").style.padding = "0";
	document.getElementById("ctl00_phF_tab_t3_edTImeClock").style.borderBottom = "0";
	document.getElementById("ctl00_phF_tab_t3_buttonStart").style.marginLeft = "10px";
	document.getElementById("ctl00_phF_tab_t3_edResult").style.padding = "0";
	
	if(ele == "CL" || ele == "CD"){
		document.getElementById("ctl00_phF_tab_t3_buttonStart").setAttribute("disabled", "true"); 	
		document.getElementById("ctl00_phF_tab_t3_buttonStart").classList.remove("ButtonH"); 
		document.getElementById("ctl00_phF_tab_t3_buttonStart").classList.add("ButtonD"); 
		
		document.getElementById("ctl00_phF_tab_t3_buttonPause").setAttribute("disabled", "true"); 	
		document.getElementById("ctl00_phF_tab_t3_buttonPause").classList.remove("ButtonH"); 
		document.getElementById("ctl00_phF_tab_t3_buttonPause").classList.add("ButtonD"); 
		
		document.getElementById("ctl00_phF_tab_t3_buttonReset").setAttribute("disabled", "true"); 	
		document.getElementById("ctl00_phF_tab_t3_buttonReset").classList.remove("ButtonH"); 
		document.getElementById("ctl00_phF_tab_t3_buttonReset").classList.add("ButtonD"); 
	}
}
window.onload = init;

在哪里???是我不知道如何实施的部分。

0 个答案:

没有答案