[user02@FC4 Lesson10]$ cat -n proto.cpp
1 #include <iostream>
2 using namespace std;
3
4 float average_value(int, int); // Function prototype
5
6 int main()
7 {
8 cout << "The average of 2000 and 2 is " << average_value(2000, 2) << endl;
9
10 return 0;
11 }
12
13 float average_value(int a, int b)
14 {
15 return((a + b) / 2.0);
16 }
[user02@FC4 Lesson10]$ g++ -o proto proto.cpp[user02@FC4 Lesson10]$ ./proto
The average of 2000 and 2 is 1001
[user02@FC4 Lesson10]$
[user02@FC4 Lesson10]$ cat -n proto2.cpp
1 #include <iostream>
2 using namespace std;
3
4 //float average_value(int, int); // Function prototype
5
6 int main()
7 {
8 cout << "The average of 2000 and 2 is " << average_value(2000, 2) << endl;
9
10 return 0;
11 }
12
13 float average_value(int a, int b)
14 {
15 return((a + b) / 2.0);
16 }
[user02@FC4 Lesson10]$ g++ -o proto2 proto2.cppproto2.cpp: In function ?eint main()?f:
proto2.cpp:8: error: ?eaverage_value?f was not declared in this scope
[user02@FC4 Lesson10]$ ./proto2
-bash: ./proto2: No such file or directory
[user02@FC4 Lesson10]$
lesson_10_proto.cpp, Rev. 1, Last changed on 2005-08-18 06:06, 314 page hits