Nepedia
Back to Discover
Independent Reader
💻

Operator overloading

technology Maturity 7-9 Next article →

Computers use special signs called operators. Most people know the plus sign. It adds numbers together. But programmers can teach these signs new ways to work. This is called operator overloading. It lets an operator do different tasks depending on what it is used with.

This is helpful for math. In science, people use big math objects called matrices. Overloading lets them use a simple plus sign to add them. This makes the code look like math on paper. It can also help sort lists. A programmer can teach the "less-than" sign how to sort new types of data.

Some people think overloading can be tricky. It can change what a sign usually means. This might surprise other coders. It can also break math rules. For example, adding words is not always the same as adding numbers. In math, $a + b$ is the same as $b + a$. But with words, the order matters. Some languages, like Java, do not use this feature. Other languages, like C++ and Python, use it often.

172 words

Where will your curiosity go next?

Keep exploring at your chosen reading level.

More to explore

What is Nepedia?

A free, ad-free encyclopedia for children. Every article is written at five reading levels, so the same page works for a five-year-old and a fifteen-year-old — use the level switcher above to see this one change. No account needed to read.