Replies: 2 comments 4 replies
-
I can see a number of C++ errors (unrelated to HomeSpan). First, all arrays in C and C++ start at 0, not 1. Also, in your for-loop you need to use a ==, not =, for comparisons. You are also trying to set a String variable to Service, instead of having the variable be a pointer to a Service. I highly recommend taking an online C++ class or two as you start to develop more complex sketches so you can focus more on the HomeSpan aspects of the sketch. |
Beta Was this translation helpful? Give feedback.
-
I'm glad you are enjoying the library and it is a good framework from which to further explore C/C++ since instead of dealing with abstract learning, you can put things into practical use. C++ is a terrific language but the syntax and some of the concepts can be a bit daunting, especially when first learning. One of the strengths of C++ is also its largest challenge - there are many different ways of accomplishing the same tasks. This is good in the sense of providing flexibility, but not so good when trying to learn. Even among the various HomeSpan examples you will see I used different styles. For example, sometimes you will see an example where I created pointers to Characteristics, other times I create them without pointers. The reason is that in some of my first examples, the initial values for the Characteristics were going to be set based on variable inputs when they were first created. This is best accomplished with using pointers and C++ also has many dozens of libraries that have been under continuous augmentation for 40+ years. Not even professional C++ developers likely use all aspects of the C++ libraries, since many of them have overlapping functions. Once you identify the few that make sense for your needs, you tend to use those and ignore the others, though sometimes you may find that another library or way of doing something gives you just the option you needed to simplify your code. Eventually you will develop your own style and adapt it as needed. Most important thing is to have fun --- programming in C++ can be frustrating, but rewarding if you stick with it. Good luck! |
Beta Was this translation helpful? Give feedback.
-
Hi there (again, same noob).
Different topic here. I'm trying to clean up a lot my code, and was starting to use a "for loop" for this line when adding a new input source :
So, I started to do something like this :
With this being how I made the Array and list :
When I see the errors I get, I suppose this is just not supported, right ?
If no, it's fine, I was just curious on trying to be smart for once 😄
Beta Was this translation helpful? Give feedback.
All reactions