Error running my work flow program

Write your question here.

I have a few errors that I can't quite figure out. The catch is red lined also my bracket in the begining. Not sure why. Stared at my screen for way too long.

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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
//
// Work Flow Assistant Program
//


#include <iostream>
#include <algorithm>
#include <cctype>
#include <iostream>
#include <map>
#include <stdexcept>
#include <string>

using namespace std;


int main()

// Get the Time Zone of the ticket 
{
	int get_TIMEZONE(std::string in)
	{
		static const std::map<std::string, int> TIMEZONE
		{
			{ "PST", 101 },{ "MST", 102 },{ "CST", 103 },{ "EST", 104 }
		};

		std::transform(in.begin(), in.end(), in.begin(), ::tolower);

		{
			auto it = timezone.find(in);
			if (it != timezone.end())
				return it->second;
		}

		if (all_of(in.begin(), in.end(), ::isdigit))
			return std::stoi(in);
		throw std::invalid_argument("Bad Time Zone string");
	}


//Get the ticket type
	int get_tickettype(std::string in)
	{
		static const std::map<std::string, int> ticketype
		{
			{ "General", 1 },{ "HandsOn", 2 }

		};

		std::transform(in.begin(), in.end(), in.begin(), ::tolower);

		{
			auto it = tickettype.find(in);
			if (it != tickettype.end())
				return it->second;
		}

		if (all_of(in.begin(), in.end(), ::isdigit))
			return std::stoi(in);
		throw std::invalid_argument("Bad Ticket Type string");
	}


//
// Start of acutal processes 
//


{

		cout << "----------Work Flow Assistant v0.7----------" << endl << endl;
		try
		{
			std::string temp;
			std::cout << "Please enter the time zone (PST, MST, CST, EST):\n";
			std::cin >> temp;
			int ou = get_timezone(std::move(temp));
	std::cout << "\nPlease enter the type of ticket (General, HandsOn:\n";
			std::cin >> temp;
			int area = get_tickettype(std::move(temp));
			std::cout << "\n\n";

//Loop to get desired tech assigned 

			if (get_timezone == 101 && get_tickettype == 1)
			{
				std::cout << "Your tech is tech1 or tech2.\n";
			}

			else if (get_timezone == 102 && get_tickettype == 1)
			{
				std::cout << "Your tech is tech1 or tech2.\n";
			}

			else if (get_timezone == 103 && get_tickettype == 1)
			{
				std::cout << "Your tech is tech1 or tech2.\n";
			}

			else if (get_timezone == 104 && get_tickettype == 1)
			{
				std::cout << "Your tech is tech1 or tech2.\n";
			}
			else if (get_timezone == 101 && get_tickettype == 2)
			{
				std::cout << "Your tech is tech1 or tech2.\n";
			}

			else if (get_timezone == 102 && get_tickettype == 2)
			{
				std::cout << "Your tech is tech1 or tech2.\n";
			}
			else if (get_timezone == 103 && get_tickettype == 2)
			{
				std::cout << "Your tech is tech1 or tech2.\n";
			}
			else if (get_timezone == 104 && get_tickettype == 2)
			{
				std::cout << "Your tech is tech1 or tech2.\n";
			}
			
		}

		catch (std::exception& e)

		{
			std::cerr << e.what();
			return EXIT_FAILURE;
		}

		system("pause");

 return 0;
}

//End of program
Last edited on
You can't have 2 mains.
I cleared that up and it still is fobar
Good catch!
You also can't have functions inside of main. That would remove the entire purpose of functions.

http://www.cplusplus.com/doc/tutorial/functions/

(There is a great deal of detailed info on how to implement functions on youtube/google.)

Edit:

Did you write this code? Becuase you are using a container such as std::map and exception handling try/catch, but you do not know how simple functions work? Either you didn't write the code yourself or you skipped over the basics of c++, in which case I would recommend you revisit.
Last edited on
I wrote it last year for something else relatable and have not coded in months. I just came back to this one to reengineer it for something else. I may have forgotten a few things, but I'll do a review tonight. However, you can do your refresher on arrogance. This should help your people skills while in public.
Last edited on
However, you can do your refresher on arrogance. This should help your people skills while in public.


Arrogance? I simply asked a question, gave reasons as to why the question was asked, and then gave you a tip. Perhaps you should remove the stick up your bum.
You also can't have functions inside of main. That would remove the entire purpose of functions.

So.. lambdas removed the entire purpose of functions? There are languages that allow nested functions. It makes things much cleaner, sometimes, if you can limit the scope of a function meant solely to be a helper for another function to the function it is meant to help. Not surprisingly, it doesn't "remove the entire purpose of functions," however.

To OP: Nested functions are not allowed in C++ (although I believe GCC allows them as a non-standard extension.) It is customary to supply the text of errors when you get them (not just say "I get some errors trying to compile this.") Help others help you.
I meant specifically inside of main, not nested functions. Sorry if that was unclear.
Topic archived. No new replies allowed.