当前位置: 首页>>代码示例>>C++>>正文


C++ BST::deleteValue方法代码示例

本文整理汇总了C++中BST::deleteValue方法的典型用法代码示例。如果您正苦于以下问题:C++ BST::deleteValue方法的具体用法?C++ BST::deleteValue怎么用?C++ BST::deleteValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BST的用法示例。


在下文中一共展示了BST::deleteValue方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main(void) {

	// EXERCISE 2
	Player player1(10);
	player1.set_name("John");

	Player player2(15);
	player2.set_name("Fred");

	cout << player1.get_name() << " has " << player1.get_hit_points() << " health" << endl;
	cout << player2.get_name() << " has " << player2.get_hit_points() << " health" << endl << endl;


	// EXERCISE 3
	BST* bst = new BST();
	bst->insertInteger(18);
	bst->insertInteger(8);
	bst->insertInteger(3);
	bst->insertInteger(23);
	bst->insertInteger(11);
	bst->printTree();

	cout << "Is 11 in BST? " << bst->searchTree(11) << endl;
	cout << "Is 5 in BST? " << bst->searchTree(5) << endl << endl;

	bst->deleteValue(18);
	bst->printTree();


	// EXERCISE 4
	Battleship* battleship = new Battleship();
	battleship->play();


	// TUTORIAL CODE
	Enemy e1(2);
	cout << "hit points = " << e1.get_hit_points() << "\n";

	Enemy* e2 = new Enemy(2);
	e2->set_hit_points(3);
	cout << "hit points = " << e2->get_hit_points() << "\n";

	e2->set_score(2);
	cout << "score = " << e2->get_score() << "\n";

	delete e2;
	e2 = NULL;

	cout << endl << "Enter a number to exit..." << endl;
	int exit;
	cin >> exit;
	return 0;
}
开发者ID:JMulligan94,项目名称:TutorialLessons,代码行数:53,代码来源:Classes.cpp


注:本文中的BST::deleteValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。