I am a relitivley new programmer. I have a question, say I wanted to name a variable “take_a_lap.” The goal of this variable is to make the robot run around the edge of the field with one command so that I don’t have to keep calling it. How do I accomplish this in c++? Did I explain this well enough?
What you’re describing is actually a function, rather than a variable. A function is a group of coding steps which are designed to be “called” more than once. This makes the code easier to read and maintain, instead of having the same code copy and pasted all over the place.
As to how you do this in C++, there’s lots of (pardon the topical pun) variables about how you go defining a function. You’re going to need to go through some C++ tutorials to learn what you need to know, and once you have that base of knowledge, you’ll be able to ask more direct questions that can be answered here.
8 Likes
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.