Skip to content

Commit 22100e0

Browse files
committed
Constructor and Destructor
1 parent 696b4bb commit 22100e0

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

07_SimpleCppApp/main.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,16 @@ int32_t f(int32_t x)
99
class FunctionPreCacher
1010
{
1111
public:
12+
FunctionPreCacher() = default;
13+
FunctionPreCacher(int32_t x, uint32_t count, int32_t(*function)(int32_t))
14+
{
15+
Setup(x, count, function);
16+
}
17+
~FunctionPreCacher()
18+
{
19+
Release();
20+
}
21+
1222
void Setup(int32_t x, uint32_t count, int32_t(*function)(int32_t))
1323
{
1424
if (!values)
@@ -69,9 +79,7 @@ int main()
6979
std::cout << "Enter the itterations: ";
7080
std::cin >> count;
7181

72-
FunctionPreCacher pc;
73-
pc.Setup(x, count, &f);
82+
FunctionPreCacher pc(x, count, &f);
7483
pc.Compute();
7584
pc.Print();
76-
pc.Release();
7785
}

0 commit comments

Comments
 (0)