-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path16.39.cpp
More file actions
26 lines (22 loc) · 858 Bytes
/
16.39.cpp
File metadata and controls
26 lines (22 loc) · 858 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include "compare.h"
#include <iostream>
#include <string>
using std::cout;
using std::endl;
using std::string;
int main() {
int result;
// Compare the two strings
result = compare<string>("hello", "bye");
cout << (result == 0 ? "The strings have equal values" :
result == 1 ? "The first string is larger than the second" :
"The second string is larger than the first") << endl;
// Compare the pointer values
result = compare<const char *>("hello", "bye"); // explicit array to pointer conversion:
// function parameters are references, won't
// implicitly convert it to a pointer
cout << (result == 0 ? "The pointers point to the same element" :
result == 1 ? "The first pointer holds an address larger than the second" :
"The second pointer holds an address larger than the first") << endl;
return 0;
}