Click here to Skip to main content
15,887,027 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: C++ interview question Pin
Cedric Moonen1-Jul-09 22:02
Cedric Moonen1-Jul-09 22:02 
GeneralRe: C++ interview question Pin
minkowski1-Jul-09 22:17
minkowski1-Jul-09 22:17 
GeneralRe: C++ interview question Pin
CPallini1-Jul-09 22:19
mveCPallini1-Jul-09 22:19 
AnswerRe: C++ interview question Pin
_AnsHUMAN_ 1-Jul-09 22:04
_AnsHUMAN_ 1-Jul-09 22:04 
GeneralRe: C++ interview question Pin
molesworth1-Jul-09 22:32
molesworth1-Jul-09 22:32 
GeneralRe: C++ interview question Pin
minkowski1-Jul-09 22:37
minkowski1-Jul-09 22:37 
GeneralRe: C++ interview question Pin
molesworth1-Jul-09 23:35
molesworth1-Jul-09 23:35 
AnswerRe: C++ interview question Pin
CPallini1-Jul-09 22:14
mveCPallini1-Jul-09 22:14 
minkowski wrote:
I said it would not compile since there is no definition (only a declaration) of the function nextChar()

Your point is correct (please note, however, that you would get a linker error, not a compiler one).



Now suppose nextChar is defined, somewhere (it's actual implementation doesn't matter).
minkowski wrote:
but the answer was 0 or 1. I am not sure why and also how can you use the != operator outside a if or while statement (i.e. something that expects true or false ?

nextChar() != '\0';

the above expression evaluates true whenever nextChar return a value different from '\0', false otherwise. Since true is 1 [^] (false is 0) an implicit cast from bool to char (that is an integer type) happens and you get ch=1 (or ch=0).
Smile | :)

BTW Are you that Minkowski [^]? Big Grin | :-D

If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.

This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke

[My articles]

JokeRe: C++ interview question Pin
toxcct1-Jul-09 22:57
toxcct1-Jul-09 22:57 
GeneralRe: C++ interview question Pin
minkowski1-Jul-09 23:10
minkowski1-Jul-09 23:10 
GeneralRe: C++ interview question Pin
CPallini1-Jul-09 23:15
mveCPallini1-Jul-09 23:15 
GeneralRe: C++ interview question Pin
UserNameless1-Jul-09 23:30
UserNameless1-Jul-09 23:30 
GeneralRe: C++ interview question Pin
CPallini1-Jul-09 23:42
mveCPallini1-Jul-09 23:42 
GeneralRe: C++ interview question Pin
minkowski2-Jul-09 1:43
minkowski2-Jul-09 1:43 
AnswerRe: C++ interview question Pin
«_Superman_»1-Jul-09 22:15
professional«_Superman_»1-Jul-09 22:15 
Question[Message Deleted] Pin
npbzy1-Jul-09 21:13
npbzy1-Jul-09 21:13 
AnswerRe: Need help in C++ progamming to output measurement automatically after manually defined points Pin
CPallini1-Jul-09 21:25
mveCPallini1-Jul-09 21:25 
General[Message Deleted] Pin
npbzy1-Jul-09 22:12
npbzy1-Jul-09 22:12 
GeneralRe: Need help in C++ progamming to output measurement automatically after manually defined points Pin
CPallini1-Jul-09 22:20
mveCPallini1-Jul-09 22:20 
QuestionHow to Use Regular Expression Pin
Pavan_Putra1-Jul-09 20:23
Pavan_Putra1-Jul-09 20:23 
AnswerRe: How to Use Regular Expression Pin
Garth J Lancaster1-Jul-09 20:46
professionalGarth J Lancaster1-Jul-09 20:46 
GeneralRe: How to Use Regular Expression Pin
«_Superman_»1-Jul-09 20:53
professional«_Superman_»1-Jul-09 20:53 
GeneralRe: How to Use Regular Expression Pin
Garth J Lancaster1-Jul-09 20:56
professionalGarth J Lancaster1-Jul-09 20:56 
AnswerRe: How to Use Regular Expression Pin
«_Superman_»1-Jul-09 20:47
professional«_Superman_»1-Jul-09 20:47 
AnswerRe: How to Use Regular Expression Pin
Jijo.Raj1-Jul-09 20:51
Jijo.Raj1-Jul-09 20:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.