Click here to Skip to main content
15,887,596 members
Home / Discussions / C#
   

C#

 
AnswerRe: How to impose Expire Date on MS Office files? Pin
Russell Jones24-Apr-07 0:04
Russell Jones24-Apr-07 0:04 
GeneralRe: How to impose Expire Date on MS Office files? [modified] Pin
sachinkalse13-Jun-07 16:36
sachinkalse13-Jun-07 16:36 
QuestionVery basic help with C++ linker/logic errors Pin
wertyou23-Apr-07 17:05
wertyou23-Apr-07 17:05 
AnswerRe: Very basic help with C++ linker/logic errors Pin
Patrick Etc.23-Apr-07 17:27
Patrick Etc.23-Apr-07 17:27 
GeneralRe: Very basic help with C++ linker/logic errors Pin
wertyou23-Apr-07 17:37
wertyou23-Apr-07 17:37 
GeneralRe: Very basic help with C++ linker/logic errors Pin
Patrick Etc.23-Apr-07 17:45
Patrick Etc.23-Apr-07 17:45 
GeneralRe: Very basic help with C++ linker/logic errors Pin
wertyou23-Apr-07 18:04
wertyou23-Apr-07 18:04 
GeneralRe: Very basic help with C++ linker/logic errors Pin
Patrick Etc.23-Apr-07 18:27
Patrick Etc.23-Apr-07 18:27 
wertyou wrote:
It's in line 58 and 60, saying
expected primary-expression before '=' token
and
expected primary-expression before '=' void


Whoops, missed that one too.

You're using this to define PI:

#define PI=3.14159

#define's don't use the equals sign - just a space, like this:

#define PI 3.14159

What you need to know here is that the compiler has a step called "Preprocessing" in which it does literal string replacement of all #define's with their values - it actually replaces those physical characters before compiling. So what the compiler is actually seeing at 3*3*PI looks like this:


cout << 3 * 3 * =3.14159;

which obviously is nonsense. That's the cause of the other error about void, too, because the compiler is getting totally confused by that equals sign.

wertyou wrote:
I kind of understand what you're saying about the math expression - I thought it was the one that was 1 for true and 0 for false- how can I tell them apart?


No, the ternary operator operates on straight booleans. It will, however, interpret 1 as true and 0 as false, but those really have little to do with how the operator works.

It's pretty simple:

return CONDITION ? TRUE_EXPRESSION : FALSE_EXPRESSION;

The operator evaluates CONDITION to be true or false and returns the corresponding expression. Then, that expression is evaluated, no matter what it is. I could be a function call; it could be an integer; it can be any valid expression, really.

So, the following are all valid uses of the ternary operator:


int result = (true) ? 1 : 0; // returns 1

string result = (1) ? "yes" : "no"; // returns "yes"

string result = (0) ? "no" : "yes"; // returns "no"

int result = (29 >= 25) ? 7 + 2 : 0; // returns 7 + 2, which evaluates to 9.

And so forth.


------------
Cheers,
Patrick

GeneralRe: Very basic help with C++ linker/logic errors Pin
wertyou23-Apr-07 18:42
wertyou23-Apr-07 18:42 
GeneralRe: Very basic help with C++ linker/logic errors Pin
Patrick Etc.23-Apr-07 18:45
Patrick Etc.23-Apr-07 18:45 
GeneralRe: Very basic help with C++ linker/logic errors Pin
wertyou24-Apr-07 14:53
wertyou24-Apr-07 14:53 
GeneralRe: Very basic help with C++ linker/logic errors Pin
Patrick Etc.24-Apr-07 15:09
Patrick Etc.24-Apr-07 15:09 
GeneralRe: Very basic help with C++ linker/logic errors Pin
wertyou24-Apr-07 15:30
wertyou24-Apr-07 15:30 
GeneralRe: Very basic help with C++ linker/logic errors Pin
Patrick Etc.24-Apr-07 15:49
Patrick Etc.24-Apr-07 15:49 
QuestionHow to enable internet explorer's "Disable script debugging option" thru code? Pin
engsrini23-Apr-07 16:25
engsrini23-Apr-07 16:25 
AnswerRe: How to enable internet explorer's "Disable script debugging option" thru code? Pin
Christian Graus23-Apr-07 16:41
protectorChristian Graus23-Apr-07 16:41 
GeneralRe: How to enable internet explorer's "Disable script debugging option" thru code? Pin
engsrini23-Apr-07 17:06
engsrini23-Apr-07 17:06 
Questionneed your help about datagridview Pin
phantanagu23-Apr-07 16:05
phantanagu23-Apr-07 16:05 
QuestionAppend WMV Files Pin
Muhammad Chitrali23-Apr-07 11:48
Muhammad Chitrali23-Apr-07 11:48 
AnswerRe: Append WMV Files Pin
Patrick Etc.23-Apr-07 14:40
Patrick Etc.23-Apr-07 14:40 
QuestionProblem with execute Stored Procedure from My app. Pin
hdv21223-Apr-07 11:05
hdv21223-Apr-07 11:05 
AnswerRe: Problem with execute Stored Procedure from My app. Pin
Colin Angus Mackay23-Apr-07 11:43
Colin Angus Mackay23-Apr-07 11:43 
AnswerRe: Problem with execute Stored Procedure from My app. Pin
Guffa23-Apr-07 13:54
Guffa23-Apr-07 13:54 
QuestionFileSystemWatcher Pin
hamidkhan23-Apr-07 10:41
hamidkhan23-Apr-07 10:41 
AnswerRe: FileSystemWatcher Pin
Dave Kreskowiak23-Apr-07 15:22
mveDave Kreskowiak23-Apr-07 15:22 

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.