O
O
oftywave2020-12-11 01:02:32
C++ / C#
oftywave, 2020-12-11 01:02:32

What is the best way to define a class?

what is the best way to declare a class, globally or inside the right blocks?
banal example written now:

class test_t 
{
public:
int a;
};
/////
struct structure_t
{
test_t test;
};

//

void preset(int& val)
{
test_t test;
...
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Ananiev, 2020-12-11
@SaNNy32

If the class describes a large resource-intensive object, then it is possible globally, but it is better to use the singleton pattern.
In other cases - locally.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question