Talk:C++ Programming/Q&A

 Welcome to the C++ Programming questions and answers page. Feel free to post any questions you have while learning to program in C++. If you have questions about this book, post them on the C++ Programming content discussion page. If you know the answer to a question, or you can improve any, go ahead and do it. After a response is given and the information is missing in the book, please add it and delete the post. (give at least 7 days after the reply, no archive is needed to be maintained of this page). You may also be interested on the material regarding this subject at Wikiversity.

how to move a text up and down using keys?
how to move a text up and down using keys?

You have to intercept the pressing of the keys, see the book example on how to get input from the keyboard and adapt it to detect those key presses, if you don't know the code for a particular key, print it to the screen after you have read it. if you think the example on how to get the keyboard data is missing something please ask again, please do sign you posts txs --Panic 14:41, 7 January 2007 (UTC)

string::find return type
Which one is right?

--DavidCary (talk) 02:32, 16 March 2009 (UTC)
 * returns an  ? -- old version of C++ Programming/Code/IO/Streams/string; but the compiler I'm using today tells me "warning: comparison between signed and unsigned integer expressions".
 * returns a  ? -- SGI reference; but the compiler I'm using today keeps telling me "error: 'size_type' was not declared in this scope".
 * returns a  ? -- another C++ reference; this seems to compile -- on this ancient compiler I'm using today. But is it portable?


 * What compiler are you using?   is the correct one, by what is on the 2003 standard.
 * Use  and the "error: 'size_type' was not declared in this scope" should be solved.  --Panic (talk) 19:06, 16 March 2009 (UTC)
 * Ah, that makes sense. Now my compiler accepts it. So actually


 * returns a
 * right? --DavidCary (talk) 04:04, 18 March 2009 (UTC)
 * Well the correct terminology is that the type is size_type, the  bit is the namespace/scope were the compiler can find a definition for it, in general a type can be the same or different across several namespaces/scopes sharing the same keyword, in this case it also exists in other namespaces/scope (ie  ) and from your previous searches it seems that some time back it was a int.
 * For what is on the standard (2003) the size_type is implementation dependent and size_t will (with a high degree of certainty) be equal to size_type (but the standard doesn't commit to it and I couldn't find a clear reason why...) --Panic (talk) 04:44, 18 March 2009 (UTC)
 * Thank you. OK, I've updated C++ Programming/Code/IO/Streams/string based on the new understanding you've given me. As always, feel free to improve that page, even if it means reverting my mis-guided edits. --DavidCary (talk) 13:58, 24 March 2009 (UTC)

mathematical operations
a c++ programe that can display mathematical operations.


 * No major problem, the only difficulty would be the output but that depends only on how much it needed to conform with the standard notation. You could output a TeX formula and render it elsewhere. --Panic (talk) 19:50, 18 May 2009 (UTC)

Ejecting optical drive
How to eject optical drive using c++ code on turbo c++ 3.0 compiler without using any windows library or header file?


 * Only possibility is to call another program that executes delete that task. That operation is dependant on the OS. --Panic (discuss • contribs) 22:09, 28 April 2011 (UTC)

MATALAB?
How does C++ compare with MATALAB? When should one use C++ instead of MATLAB? When is C++ superior to MATLAB? When is MATLAB superior to C++?


 * That is a bit like discussing what the differences are between oranges and apples, even more problematic since the analogy is even closer since both are fruits.
 * C++ is a programming language MATLAB is not even if it is scriptable the functions or objectives rarely are the same (MATLAB can be used to examine algorithms). Since they really can't be directly compared (unless we define a specific problem that can be addressed by both) the comparison has no meaning in generic terms, each does what it they are proposed to do. Also consider that MATLAB is a commercial product there is some fairly recent products that already replicate some functionalities of that software package in the case of programming languages there is no direct concurrency, there is only one C++ language even if some other languages can perform the same tasks they are ultimately completely distinct in use, capabilities and results (see the book section that compares C++ with similar languages if you need further info on that). --Panic (discuss • contribs) 08:39, 1 June 2011 (UTC)

c++ programming logical
A=9,B=9 why C=A!=B+1+(A==B) get the result C=0 ?


 * Go by steps and check operator resolution priority on the table. In any case doing such logic in a single operation like that is bad coding practice, you can extend it into several operations unless compiler optimization needs to be turned off, in that case you should provide an appropriate comment. --Panic (discuss • contribs) 09:44, 4 February 2012 (UTC)

Programming terms
hello there, I don't know anything about programming c++, but i ran on these words and would like to know what they are or how to get them: can you help pls?


 * - initial interface
 * - data loggin
 * - polling system
 * - object inspector
 * - gage component

thanks a lot


 * This have no specific relation to C++, even if they can be declared as terms used in programming. All depend on the context they are used so it would be mostly guessing to what they mean as listed above.
 * An interface can be many things but lets assume it refers to classes, in that case the initial interface may be indicating the parent class interface before derivation.
 * Data logging relates to keeping "data" for review (a log).
 * Polling system may be something like detecting if a system is active (for instance in dealing with threads) or in networks it can also be referring to deciding a priority by a vote (see distributed systems).
 * Object inspector is just like it states, you should learn more about Object Oriented Programming first.
 * The gage component can be so many things that I will not conjecture about it.
 * Programming is hard, it is not only understanding a language but knowing what can be done with it, understanding all the intrinsics of a language. Knowing the code is even less important that fully understanding the concepts behind how and why things are implemented as they are. If you understand those, every language will become very similar to you, as they ultimately share the same basic functional purpose. --Panic (discuss • contribs) 19:11, 2 May 2012 (UTC)

C++
what's the difference between \n & endl;


 * The first is a legacy notation from many older languages including C, the latest (I guess you intended to refer to std::endl) behavior is mostly equivalent but has further uses (streams) and guarantees see for example what was answered here, provides a complete coverage of the issue. --Panic (discuss • contribs) 23:32, 26 January 2015 (UTC)

the hello world example
Hi guys,

I am trying to learn C++ using your book. But the hello world example is confusing!

Here is why:

- the use of "int" before "main" is explained much later than it should be;

- the explanation claims that the first line of the program contains a line ending in \n and then waxes lyrical about what this means but the first line of the example does not contain \n !

raj 203.214.45.199 (discuss) 05:03, 13 July 2023 (UTC)