Global variables in C++ -


I should write a program that should be read from the input number in the main () part, and then counting some other boolean work numbers I do not want to include all the other parameters in the entire array and function while I call them.

My question is: Can I create some variables in C ++ to read the input, but in a way that other functions outside of main () also give these variables "address "And what is inside them? When I call the function, do not have to put too many arguments?

This code is:

  #include & lt; Iostream & gt; using namespace std; Inline bool del (int n) {int i; {If ((n% a [i]) == 0) back to true (I = 0; i & lt; s1; i ++); }     return false; } Inline Bull Ned (Int N) {int i; (I (i =); i (i <) i ++) (if ((n% b [i]) = 0) true true;} description is false;} main main (zero) {intrate s 1, S2, a [25], b [25]; int m, n, i, k = 0; bool d, nd; cin> gt; s1> gt; s2> For i & lt; i ++) cin & gt; & gt; A [i]; for (i = 0; i & lt; i & gt; i & (I = m; i ++) {d = del (i); nd = ned for (i); for b [i] cin & gt; (I); if (D == true & amp; nd == true) ++ K;} Cout ; k  

int s1, s2, a [25], b [25] & lt; - these are the ones that I want to be seen by other functions (Because I can use them as you can see).

I tried to declare them as global, but it did not work, I found such errors as "in this area

Thanks for helping.

>

This Creating a variable global for a reason is a bad habit, or just pass the arrays in the works, or the whole thing is created in an object S create Arejh and function members of classes. OOP is about this.


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -