⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cpp12.cpp

📁 C++参考书
💻 CPP
字号:

// Coded by plusir -- Dec.28.2002.
// Standard C++ Bible -- (P166-6-12)

#include <iostream>
using namespace std ;

inline void fileFunc( void ) { cout << "File Function" << endl ; }
inline void editFunc( void ) { cout << "Edit Function" << endl ; }
inline void viewFunc( void ) { cout << "View Function" << endl ; }
inline void exitFunc( void ) { cout << "Exit Function" << endl ; }

struct Menu
{
	char *name ;
	void( *fn )( void ) ;
} ;

Menu menu[] = {
	{ "File", fileFunc },
	{ "Edit", editFunc },
	{ "View", viewFunc },
	{ "Exit", exitFunc }
} ;

int main()
{
	int select ;

	while ( select != 4 ) {
        
		for ( int i = 0; i < 4; ++i )
			cout << i + 1 << ": " << menu[i].name << endl ;
		cout << "Select: " ;
		cin >> select ;

		if ( select < 5 )
			( *menu[select - 1].fn )() ;
	}

	return 0 ;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -