lesson 10 proto cpp
[[lesson_10_proto_cpp]] last edit on
Aug 18, 2005
6:06 AM
by rescued_by_c
[user02@FC4 Lesson10]$ cat -n proto.cpp
[user02@FC4 Lesson10]$ ./proto
The average of 2000 and 2 is 1001
[user02@FC4 Lesson10]$
[user02@FC4 Lesson10]$ cat -n proto2.cpp
proto2.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]$
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]$