I'm reading the book "Training in C ++ Language", but this teaching everything error. The hello world
of the book simply does not compile:
#include <iostream.h>
void main() {
cout << "Primeiro Programa";
}
If the book is really bad, throw it away and look for a better one.
You have some problems in this code
.h
as in C. It is the statement of cout
. main()
function must be an integer. cout
needs your full name, that is, std::cout
. So it compiles:
#include <iostream>
int main() {
std::cout << "Primeiro Programa";
}
See running on ideone . And no Coding Ground . Also I placed GitHub for future reference .
A variation used when the program starts to become more complex (not that it compensates in this case, only to show something very used):
#include <iostream>
using std;
int main() {
cout << "Primeiro Programa";
}