3
If it really is like this the book is very bad, throw it away and look for a better.
There are some problems in this code
- In C++ include files do not carry the suffix
.h
as in C. Therein lies the statement ofcout
(the files are usually.hpp
but import in the code does not use the extension). - Function definitions must have parentheses after their name.
- The return of function
main()
must be a whole. - The
cout
need your full name, ie,std::cout
.
Thus compiles:
#include <iostream>
int main() {
std::cout << "Primeiro Programa";
}
Behold working in the ideone. And in the repl it.. Also put on the 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";
}
I’m reading the pdf version.
– Leonardo
Then you don’t have to throw it away, just delete :P
– Bacco
I’ll do just that, garbage book!!
– Leonardo
http://www.pontov.com.br/files/cpp/roadmapcpp/ApostilaProgrampCppv045.pdf. Staff also like Deitel’s "C++ How to Program" (this one has to buy).
– Maniero
I see from the workbook, it looks good...
– Leonardo
Incredibly this is a variation of the first example of the book How not to program in C++. If you’re curious, this code goes against standards, but it looks like several things that compile (or at least compile) into a series of compilers (bad).
– Anthony Accioly
@Leonardo I don’t know, but it might not be bad, just too old, it’s pre-standard code, a time in the history of C++ has already been valid. Particularly not recommend Deitel, too giant, curls too much, not so modern. C++ Primer for beginner is good, Effective Modern C++ to be more on the inside. The Stroustrup, creator of language, are also updated and good, he has books that cover all language, as aimed at beginners also.
– pepper_chico
It Has A Detail It Doesn’t Have to Be int main(), No Visual C++ 2013 Quiet Wheel Like Void I Hate It That Put
– axell-brendow
http://answall.com/a/43252/101
– Maniero