Calling into the main function

I'm stuck, I've been trying to call these into the main(); and I've tried several different things, but nothing is going right. Please help me.

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
#include<iostream>
#include<iomanip>
using namespace std;
void convert(int, int&, int&, int&);
class Time
{
public:
	int hour, minute, second;
	Time(int h, int m, int s)
	{
		hour = h;
		minute = m;
		second = s;
	}
	void get()
	{
		cout << "Enter the time\n";
		cout << "Hour: ";
		cin >> hour;
		cout << "Minutes: ";
		cin >> minute;
		cout << "Seconds: ";
		cin >> second;
	}
	void show()
	{
		cout << setw(2) << setfill('0') << hour << ":" << setw(2) << setfill('0') << minute << ":" << setw(2) << setfill('0') << second << endl;
		return;
	}
	void militaryTime(int h, int m)
	{
		int h1 = (h + 12);
		cout << h1 << ":" << m;
		return;

	}
	void standardTime(int h, int m)
	{
		cout << h << ":" << m;
		return;
	}
	void changeTime(int h, int m, int s)
	{
		int h2 = (h + 2) < 12;
		int m2 = (m + 12) < 60;
		int s2 = (s + 1) < 60;
		cout << h2 << ":" << m2 << ":" << s2;
		return;
	}
	void convert(int totalsec, int& h, int& m, int& s)
	{
		s = totalsec % 60;
		totalsec = totalsec / 60;
		m = totalsec % 60;
		h = (totalsec / 60) % 12;
		if (h == 0)
			h = 12;
		return;
	}
};

int main()
{
	Time();
	system("pause");
}
Does this even compile?
probably, only if I could figure out how to call the functions in main()
it does compile, it just can't give me what i want out of it yet
To call the methods you've defined, you have to create an instance of your time class.
Time timeInstance;
Then you may call the methods on it:
timeInstace.get();

I would recommend that those methods that output times in certain styles just use the fields instead of taking in parameters; otherwise that defeats the point of having them in the class, I think.
@Zhuge you are a lifesaver!!Thank you So Much
Topic archived. No new replies allowed.