PDA

View Full Version : Computers any C++ experts out there?


ILChief
08-03-2008, 02:58 PM
what does an exclamation point preceding a varible name in an if statement mean?

example

if (!variablex)
return FALSE ;

Is it saying if variable x is not equal to zero, return false or am I way off?

Thanks

Any help is appreciated

Baby Lee
08-03-2008, 03:16 PM
I don't know about C++, but in C, the syntax for if with a ! interrogative is

if (vara != varb)

Shag
08-03-2008, 03:38 PM
I'm not a C++ guy, but in other languages, that would mean "if not variablex". I believe the if statement will evaluate true if variablex = 0. Any non-zero value will evaluate false.

Fish
08-03-2008, 04:50 PM
NOT

ILChief
08-03-2008, 04:53 PM
NOT


not what?

dj56dt58
08-03-2008, 04:57 PM
not what?

not..whatever is after it

!=not

!0 = not 0

anyone know anything about php(shopping carts)?

Fish
08-03-2008, 05:11 PM
not what?

Yes. !what

SLAG
08-03-2008, 09:55 PM
anyone know anything about php(shopping carts)?

like drupal's ecommerece mod?

cdcox
08-03-2008, 10:24 PM
what does an exclamation point preceding a varible name in an if statement mean?

example

if (!variablex)
return FALSE ;

Is it saying if variable x is not equal to zero, return false or am I way off?

Thanks

Any help is appreciated


As others have pointed out, ! preceeding a variable means NOT.

I presume variablex is of type boolean (i.e. has values of "true" or "false").

So we have two cases:

1) when variablex has the value "true"

!variablex evaluates as "false" and the statement(s) following the if statment would not be executed.

2) when variablex has the value of "false"

!variablex evaluates as "true" and the statement(s) following the if statement would be executed.

ILChief
08-04-2008, 12:49 PM
Thanks to all that replied. I have one more question:

What does a "^" mean if it is before a variable name?

For example, when declaring a String variable:

String ^variablex
-----------------
Thanks for any help

phisherman
08-04-2008, 01:01 PM
^, or xor, is usually an operator used for booleans and integers. never heard of it being used for a string

haven't thought of that in a while, and for that matter, i never used a xor in code.

HC_Chief
08-04-2008, 02:41 PM
http://c2.com/cgi/wiki?CeePlusPlus

dj56dt58
08-04-2008, 11:21 PM
like drupal's ecommerece mod?

not sure..just been thinkin about learning php so i can create shopping carts..doesn't look easy

kepp
08-07-2008, 07:58 AM
We do our own homework around here, son. Eyes on your own paper.