0
Can I set an variable to a value in my class, and declare it in int main?
I created a program that used a class that had you set a variable to a certain value. Then in in int main I declared these variables. And then I called the function in main after I had declared the variables. But I got an error saying I didn't declare the variable despite the fact that I declared the variable in main before accessing it from my class.
3 Antworten
0
You can't access the variables of a function from another function
, you need to return the value and assign it in main.
0
No you can't access it directly but if you have a global variable then you can do something take look at my code:
https://code.sololearn.com/c7bcCU4qa7Qw/?ref=app
0
You have to know the basics of the pointer to understand it!