A
A
Andrey Begin2020-12-12 03:59:24
C++ / C#
Andrey Begin, 2020-12-12 03:59:24

Transferring data as a separate block?

I need to pass some block of data to another function at once.
The main problem is not to use a struct or a class. Since the transfer occurs in only one fragment of a huge code, you don’t want to pile up something from this.

I wanted to resort to a lambda, but I never found a way to pull values ​​when passing a pointer.
Passing values ​​not in a block, but in parts is also not suitable, since it is likely that there will be more and more variables in the future.

Example : pass variables A, B, C, D of different types once to function F for data processing
Task : do not use structures and classes, be able to process all values.

Recently in some code I saw a similar structure - func( {int A, int B}, float C).

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Adamos, 2020-12-12
@Adamos

The main problem is not to use a struct or a class. Since the transfer occurs in only one fragment of a huge code, you don’t want to pile up something from this.

Weird phobia. Take a sedative and write the same structure, specially designed for such interactions and invented. You spent more energy on this question than on the correct (that is, supported) solution to your problem. A bunch of tricks for such garbage, just to avoid six extra lines in the class description, will be much more evil. Especially if
variables in the future will become more and more.

V
vizionaire, 2020-12-12
@vizionaire

You can use char*

typedef char* pbyte;
func(pbyte pblock, int len); //len - длина данных

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question