D
D
Diell2020-05-23 14:03:21
C++ / C#
Diell, 2020-05-23 14:03:21

How does passing variables to classes work?

I read a lot of explanations but did not get how it works.
There is a set of variables that need to be used in different classes, there are classes where these variables are used, for example a=0 initially, in one class the variable is a=a+1 and in another class a=a+2, respectively a=3, like this do? You can give an example of where what should be written, how to include files with variables, how to declare them ... I
have read a lot, but I still can’t figure out how it should look like ....

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Korotenko, 2020-05-23
@Diell

Class Variables{ public static int A=5;}
Variables.A = 7;
More or less like this.
It is possible through the constructor
Var f =5;
Var instance = new YouClass(f);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question