| dumb0t (21) | |
|
i was wondering if i theres a way to make a bunch of variables and only the class functions can change the values. And whoever wants to access it from outside the class can only view the value, but changing is not allowed. Is it possible, without making a get function for every variable? EDIT:: nvm, i know what im gonna do now, just gonna make a class for each variable so if in the future i want to add more, im just gonna add another instance of the class | |
|
Last edited on
|
|
| ne555 (4385) | |||
I don't understand your solution, ¿mind to post code?
| |||
|
|
|||
| Raezzor (277) | |
| Couldn't you simply declare the variables as const? But yes, you can simply create a class with no functions that alter the data members. As for getting the data members, you can only return one object with a function, so to get more then one data member you would either need to make one getter for each or use a container or something similar. I suppose there could be some creative ways to do that too, just nothing I can think of off the top of my head. | |
|
|
|
| dumb0t (21) | |||
this is what i did, im too lazy to take out the important stuff, so just read away....xD so instead of making a bunch of variables or unsized arrays, i just made a class for every variable im gonna make..and make all the variables private and just make a getmethods for views only | |||
|
|
|||
| dumb0t (21) | |
|
i havent tested it yet though but im sure the nValue and fValue will work as i had tested them on my last cpp project, i just dont know if the sValue function will really return string though, i hope, or maybe i should make it char? EDIT:: nvm this as this is about windows c++ programming...xD | |
|
Last edited on
|
|