# A beginner question about classes

• 03-18-2012
Andrej Simeski
A beginner question about classes
Code:

```#include <string> #include <vector> #include <iostream> using namespace std; class TimeDifference {   public:     int x,y,z,seconds(string time1, string time2) {         cin >> time1 >> time2;         x=(time1[0]*10+time1[1])-(time2[0]*10+time2[1]);         y=(time1[3]*10+time1[4])-(time2[3]*10+time2[4]);         z=(time1[6]*10+time1[7])-(time2[6]*10+time2[7]); return x*3600+y*60+z;   } };```
This is my code. Basically you need to input time in format 11:45:30 and 11:45:45 for example. It should calculate the seconds difference between the two times. I get an error saying "undefined reference to WinMain@16". Please help ASAP. Thanks in advance :)
• 03-18-2012
manasij7479
Read the following (as you seem to have a broken understanding of these stuff):
Functions (I) - C++ Documentation
Functions (II) - C++ Documentation
Classes (I) - C++ Documentation
Classes (II) - C++ Documentation
[7] Classes and objects, C++ FAQ

Also, it's convenient to use stringstreams to parse the time strings.
• 03-18-2012
Elysia
• 03-18-2012
manasij7479
What good would that do, without a main function ?
• 03-18-2012
Elysia
It will solve the "undefined reference to WinMain@16" error.
I am assuming there should be a main function somewhere.
• 03-20-2012
jsrig88
Wait, for one thing, move the "seconds(string time1, string time2)" thing to its own line, like this:

Code:

`int seconds(string time1, string time2)`
• 03-20-2012
phantomotap
Nicely done Andrej Simeski; that is a wonderful bit of obfuscation.

Ah, I didn't notice that this had just been bumped from a couple days back. Sorry.
[/Edit]

Soma