NEED HELP ASAP - Runtime question

I have a question for this assignment that I need completed by tonight and i'm stuck! I'm getting an error in compiling at the t1.setTime1() function.

Thanks!

Below is the question.

Write a program in which you create a const whose value is determined at runtime by reading the time when the program starts (hint: use the <ctime> standard header). In a separate function, have the program create two arrays of 10,000 doubles. Initialize the first array with sequential integral values starting with 100, and initialize the second array with the same numbers, but in reverse order (i.e., the first array would contain 100, 101, 102… while the second array contains 10,099, 10,098, 10,097…). Loop through both arrays using a single loop, and multiply the corresponding array elements from each array together and display the result. Read the time when the program completes the multiplication, and compute and display the elapsed time. Do not use inline functions in this program. Rewrite program 1 using an inline function to perform the calculation. In the test plan for this program (actual results section), compare the time required by this program to execute against the time required by the first (non-inline) program.

Here is what I currently have

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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include <iostream>
#include <fstream>
#include <ctime>
#include <string>
using namespace std;

class ArrayTime
{
	public:
		void loop();
		void setTime1(clock_t t3);
		void setTime2(clock_t t2);
		char getTime1();
		char getTime2();

private:
		clock_t t3, t2;

};

int main()
{
	ArrayTime t1;
	t1.setTime1();
	t1.loop();
	t1.setTime2();

	float diff = ((float)t1.getTime2() - (float)t1.getTime1())/10000.0F;
	cout << "The run time is: " << diff << "\n";
	cin.ignore();
}



clock_t ArrayTime::setTime1(clock_t t3)
{
	t3 = clock();
}

clock_t ArrayTime::setTime2(clock_t t2)
{
	t2 = clock();
}

void ArrayTime::getTime1()
{
	return t3;
}

void ArrayTime::getTime2()
{
	return t2;
}

void ArrayTime::loop()
{
	double number1 = 100;
	double number2 = 10099;
	double array1[10000];
	double array2[10000];

	for(int i = 0; i <10000; i++)
	{
		array1[i]= number1;
		array2[i] = number2;

		const double result = array1[i]* array2[i];

		number1++;
		number2--;
	}
Line 11 a parameter t3 of type clock_t is used
 
    void setTime1(clock_t t3);


Line 24
 
    t1.setTime1();
there is no parameter supplied when calling the function.

Line 37
 
    t3 = clock();

what is t3? is it the parameter passed when the function is called? Or is it the member variable defined at line 17?

It looks like the latter. In which case, there is no need for the parameter in the function call - modify the function accordingly at lines 11 and 35 to remove the parameter.
Topic archived. No new replies allowed.