Hello! / "Classes" help!

Hello all. Newbie here!
So Im trying to learn how Visual Express works. I did very little programming before using Dev(??) compiler where all of your code was in one big edit box. Now I can have multiple files and I think its mixing me up.

In my "project" I have a working class cpp already created with a header file and you want to use it in my main cpp file.
I am just having trouble remembering how to 'call' or 'reference' the class in my main file.

Ignore all of the commented out scratch work. I have an understanding of what I need to do in my loops etc, but how do I link the Timer class to my main cpp?
The way I have it now it doesn't error out the "class Timer;" but in my main portion it tells me "Timer.start();" is incomplete which tells me I am not correctly linking the class to this bit of code.

It is a timer object to, well, time things. hah

Thanks in advance! Sorry for the long post I know how that is annoying.
Alex

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
  
#include <iostream>
using namespace std;

class Timer;

int main()
{	double b = 1.8;
	Timer.start();
//
//	do
//	{b*b
//
//	i++;
//	}
//	while {i < 999999999999};
// return 0;
//}
//
////
//	timer.start();
//for (long int i=0; i>999,999,999,999; i++) double x=q*q;
//timerMult.stop();
//cout << "Time for squaring a double by multiplication is " << timer.getElapsedTimeInMicroSeconds() << " microseconds" << endl << endl;
//double mult = get.ElapsedTimeInMicroSeconds();
//
//
//do
//{
//........
//i++;
//} while (i < 999999999999);
//  
Last edited on
All you need to do is drag and drop your main.cpp and your timer.cpp into the "sources" folder in your solution explorer if they aren't already there. Then #include the header in both sources.
1
2
3
4
5
6
7
#include "Timer.h"

#int main()
{
    Timer.start();
    // ...
}
I have 3 files in my project.
Under the "header files" is the "Timer.h"
Under the "Source code" files is "Timer.cpp" and my "main.cpp"

Isnt there a way to call or reference my timer code into my main without having to copy and paste all of the code into one big edit box?

Thanks for the response.
Topic archived. No new replies allowed.