cpp17.cpp

来自「C++参考书」· C++ 代码 · 共 42 行

CPP
42
字号

// Coded by plusir -- Dec.28.2002.
// Standard C++ Bible -- (P175-6-17)

#include <iostream>
#include <cstdlib>
using namespace std ;

struct Employee
{
	short int emplno ;
	char *name ;
	float salary ;
} ;

void showEmployee( const Employee * ) ;

int main()
{
	Employee *emp ;
	emp = ( Employee* )malloc( sizeof( Employee ) ) ;

	if ( emp != 0 ) {
		emp->emplno = 123 ;
		emp->name = "Jones" ;
		emp->salary = 37500 ;

		showEmployee( emp ) ;

		free( emp ) ;
	}

	return 0 ;
}

void showEmployee( const Employee *emp )
{
	cout << "Empl#: " << emp->emplno << endl ;
	cout << "Name: " << emp->name << endl ;
	cout << "Salary: " << emp->salary << endl ;
}

⌨️ 快捷键说明

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