Go Down

Topic: How to use class-specific variables in a function? (Read 1 time) previous topic - next topic

Nick Gammon


I give up on this thread.


Oh, OK.

Quote
But can you even put a struct in a class?


Yes you can do that.

You can use "get" and "set" methods if you want to hide the struct from the user. I'm sorry, it isn't clear what you are doing. If you want to give up, fair enough. You may want to read a C++ tutorial to get the basics of using classes and structures.
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

Yeah there is some misunderstanding I'm having about how a class works compared to a sketch (sort of in it's own terms I suppose) so I'll need to read up more on syntax cuz I'm missing something. And YES that would work too! I could create a private struct and then create method that (in English) returns the value of a value of the struct! That is the exactly the thing I was looking for in the first place! Thank you! See I just hadn't thought of that. I thought that if I had a struct in a class I'd have to somehow call an entry of the struct outside the class. But I see now if I use a method instead of directly trying to reach it I can keep it private and tucked away, which is the whole point of me trying to make this library!  :)

can you post what you have? i cant figure it out plz help

Go Up