-5

I was coding in PHP for few weeks, but now I want to learn C++.

This is my code:

$variable = 16;
std::cout << variable;

What's wrong with this?

  • `$variable` is an illegal name for a variable in c++ see: http://stackoverflow.com/questions/7926394/in-variable-name plus it has no type such as `int`, `double` etc. – EdChum Jul 22 '15 at 10:00
  • 4
    Do not just guess how C++ might work, you will fail horribly. Read a [good book](http://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list) to learn C++ systematically. – Baum mit Augen Jul 22 '15 at 10:02

1 Answers1

2
  1. Use google.
  2. In C++ you must define a type of variable.
  3. Look for a C++ tutorial, there are many of them.
  4. Use google.
arek24
  • 36
  • 5
  • 4
    5. get a [decent book on C++](http://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list). 6. read it. (Actually these should be 1. and 2.) – Paul R Jul 22 '15 at 10:07