BogCyg / BookCpp

Contains code of the book "Introduction to Programming with C++ for Engineers" by prof. Bogusław Cyganek, Wiley-IEEE, 2020
48 stars 18 forks source link

typos in source code of chapter 1 Variables.cpp #2

Open georgiosdoumas opened 10 months ago

georgiosdoumas commented 10 months ago

https://github.com/BogCyg/BookCpp/blob/master/CCppBookCode/src/Variables.cpp inside function VariablesConstWithInitialization()

Current line : //int x(); // z is int and set to 0?? No !! Correct line should be : //int x(); // x is int and set to 0?? No !!

Current line : int y( 100 ); // Ok, var x with 100 Correct line should be : int y( 100 ); // Ok, var y with 100

Also in the same area of code , it is better to have the line std::cout << "Area = " << kPi radius radius; as std::cout << "Area = " << kPi radius radius << endl; for better output.

BogCyg commented 10 months ago

Dear Doumas,

Thank you very much. I’ll fix these in the code, as well as I’ll add them to the errata file which I’m preparing.

Writing a book is a tremendous endeavor, so errors like these happen. Therefore, if you find more, then please send them to me.

Once again, thanks for your help, and sorry for the errors,

Boguslaw

From: Doumas Georgios (Δούμας Γεώργιος) @.> Sent: Saturday, November 18, 2023 9:49 AM To: BogCyg/BookCpp @.> Cc: Subscribed @.***> Subject: [BogCyg/BookCpp] typos in source code of chapter 1 Variables.cpp (Issue #2)

https://github.com/BogCyg/BookCpp/blob/master/CCppBookCode/src/Variables.cpp inside function VariablesConstWithInitialization()

Current line : //int x(); // z is int and set to 0?? No !! Correct line should be : //int x(); // x is int and set to 0?? No !!

Current line : int y( 100 ); // Ok, var x with 100 Correct line should be : int y( 100 ); // Ok, var y with 100

Also in the same area of code , it is better to have the line std::cout << "Area = " << kPi radius radius; as std::cout << "Area = " << kPi radius radius << endl; for better output.

— Reply to this email directly, view it on GitHub https://github.com/BogCyg/BookCpp/issues/2 , or unsubscribe https://github.com/notifications/unsubscribe-auth/AHXFS5WKZBWCPCK3EI44GUDYFBY7HAVCNFSM6AAAAAA7Q2NHMCVHI2DSMVQWIX3LMV43ASLTON2WKOZSGAYDAMZSGY4DENY . You are receiving this because you are subscribed to this thread.Message ID: @.***>

georgiosdoumas commented 10 months ago

Sure , I will report with new issues for each different program file. So on this one there is something more: Line: using std::wcout, std::endl, std::wstring, std::vector, std::make_unique; (before MoreOnBasicTypes() ) The std::make_unique complains during compilation, because there is no #include <memory> at an earlier line. The include is at the line just before the function HeapAllocExample() So I suggest to place the #include <memory> at the top , for example after the line of #include <cmath>

And I suggest to finish the file with a small main() , for example I constructed the following : int main(void) { BasicTypes_Examples(); MoreOnBasicTypes(); VariablesConstWithInitialization(); var_test_fun(); //do_action_N_times(3, 7); // uncomment it for a different build, and behavior do_action_test(); HeapAllocExample(); auto_test(); }

BogCyg commented 10 months ago

Thanks!

Boguslaw

From: Doumas Georgios (Δούμας Γεώργιος) @.> Sent: Saturday, November 18, 2023 6:20 PM To: BogCyg/BookCpp @.> Cc: Bogusław Cyganek @.>; Comment @.> Subject: Re: [BogCyg/BookCpp] typos in source code of chapter 1 Variables.cpp (Issue #2)

Sure , I will report with new issues for each different program file. So on this one there is something more: Line: using std::wcout, std::endl, std::wstring, std::vector, std::make_unique; (before MoreOnBasicTypes() ) The std::make_unique complains during compilation, because there is no

include

at an earlier line. The include is at the line just before the function HeapAllocExample() So I suggest to place the

include at the top , for example after the line of

include

And I suggest to finish the file with a small main() , for example I constructed the following : int main(void) { BasicTypes_Examples(); MoreOnBasicTypes(); VariablesConstWithInitialization(); var_test_fun(); //do_action_N_times(3, 7); // uncomment it for a different build, and behavior do_action_test(); HeapAllocExample(); auto_test(); }

— Reply to this email directly, view it on GitHub https://github.com/BogCyg/BookCpp/issues/2#issuecomment-1817575210 , or unsubscribe https://github.com/notifications/unsubscribe-auth/AHXFS5QRZ4TDVTH5PAM563DYFDU4HAVCNFSM6AAAAAA7Q2NHMCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMJXGU3TKMRRGA . You are receiving this because you commented.Message ID: @.***>