5

I'm writing a program and have a function named "move". But it's highlighted in my codeblocks? Is move a reserved word in c++? If so, what does it do?

I have it as void move( double t, double u)
Ebbe M. Pedersen
  • 7,250
  • 3
  • 27
  • 47
Alex
  • 119
  • 3
  • 9

1 Answers1

4

It's not a keyword, but there is a commonly-used standard library function called std::move; whoever set up your IDE's syntax highlighting decided to highlight it.

To avoid confusion with people reading your code, it'd be a good idea to call your function something else.

M.M
  • 138,810
  • 21
  • 208
  • 365
  • 1
    OP should look into namespaces before deciding to change the name of the function. –  Jul 03 '16 at 23:37
  • 4
    @xboi209 I think it's a good idea to change the name anyway. Just because you *can* call a function move, doesn't mean you *should* – M.M Jul 03 '16 at 23:40
  • I agree with @M.M, this used to confused me a lot when I first started programming. – S A Jul 04 '16 at 00:23
  • 3
    The reason for having namespaces is so that you can use descriptive names without fear of collision. `std::move` and `physics::move` are obviously two different functions, and unless someone has added the `using namespace std;` abomination there's no reason to worry about someone misunderstanding them. – Pete Becker Jul 04 '16 at 01:11
  • What @PeteBecker said is right, as long as all functions are qualified by their appropriate namespaces, using the same name as a standard library function shouldn't matter. –  Jul 04 '16 at 02:05