C++ primer plus(第六版)编程练习答案 第7章C++的编程模块

一、程序清单

calling.cpp

// calling.cpp -- defining, prototyping, and calling a function
#include <iostream>

void simple();    // function prototype

int main()
{
	using namespace std;
	cout << "main() will call the simple() function:\n";
	simple();     // function call
	cout << "main() is finished with the simple() function.\n";
	// cin.get();
	return 0;
}

// function definition
void simple()
{
	using namespace std;
	cout << "I'm but a simple function.\n";
}

输出结果:

main() will call the simple() function:
I'm but a simple function.
main() is finished with the simple() function.

protos.cpp 

// protos.cpp -- using prototypes and function calls
#include <iostream>
void cheers(int);       // prototype: no return value
double cube(double x);  // prototype: returns a double
int main()
{
	using namespace std;
	

猜你喜欢

转载自blog.csdn.net/qq_43445867/article/details/129781228