1#include <iostream>
2#include <ctime>
3
4using namespace std;
5
6// function to generate and retrun random numbers.
7int * getRandom( ) {
8
9 static int r[10];
10
11 // set the seed
12 srand( (unsigned)time( NULL ) );
13
14 for (int i = 0; i < 10; ++i) {
15 r[i] = rand();
16 cout << r[i] << endl;
17 }
18
19 return r;
20}
21
22// main function to call above defined function.
23int main () {
24
25 // a pointer to an int.
26 int *p;
27
28 p = getRandom();
29
30 for ( int i = 0; i < 10; i++ ) {
31 cout << "*(p + " << i << ") : ";
32 cout << *(p + i) << endl;
33 }
34
35 return 0;
36}
1string* getNames() {
2 string* names = new string[3];
3 names[0] = "Simon";
4 names[1] = "Peter";
5 names[2] = "Dave";
6
7 return names;
8}
9