4
4
5
5
#include " boost/algorithm/string.hpp"
6
6
7
- void apply_rsg (const std::vector<int > ringstellung, Enigma* eg)
7
+ void apply_rsg (const std::vector<int > ringstellung, Enigma& eg)
8
8
{
9
9
for (unsigned int i{0 }; i < ringstellung.size (); ++i)
10
10
{
11
- eg-> ringstellung (eg-> getRotorLabels ()[i], ringstellung[i]);
11
+ eg. ringstellung (eg. getRotorLabels ()[i], ringstellung[i]);
12
12
}
13
13
}
14
14
@@ -24,7 +24,7 @@ bool is_word(const std::string& s)
24
24
25
25
int main (int argc, char ** argv)
26
26
{
27
- Enigma* enigma = new Enigma;
27
+
28
28
std::string eg_version = EnigmaInfo::version;
29
29
30
30
if (EnigmaInfo::isBeta)
@@ -123,7 +123,9 @@ int main(int argc, char** argv)
123
123
rotors.push_back (_temp);
124
124
}
125
125
}
126
- enigma = new Enigma (rotors, ' B' , (key.size () == 3 ) ? " M3" : " M4" , false );
126
+
127
+ auto enigma = std::make_unique<Enigma>(rotors, ' B' , (key.size () == 3 ) ? " M3" : " M4" , false );
128
+
127
129
enigma->set_key (key);
128
130
129
131
std::vector<int > rsg_settings = {0 ,0 ,0 ,0 };
@@ -177,7 +179,7 @@ int main(int argc, char** argv)
177
179
rsg_settings.push_back (_temp);
178
180
}
179
181
180
- apply_rsg (rsg_settings, enigma);
182
+ apply_rsg (rsg_settings, * enigma);
181
183
}
182
184
183
185
char input[100 ] = {0 };
@@ -193,7 +195,7 @@ int main(int argc, char** argv)
193
195
std::cout << " Resetting Machine..." << std::endl;
194
196
enigma->reset ();
195
197
enigma->set_key (key);
196
- apply_rsg (rsg_settings, enigma);
198
+ apply_rsg (rsg_settings, * enigma);
197
199
}
198
200
else
199
201
{
0 commit comments