TO CHAINSAW - or anybody else who knows C++

Please support our C++ advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Aug 2004
Posts: 350
Reputation: Ghost is an unknown quantity at this point 
Solved Threads: 2
Ghost's Avatar
Ghost Ghost is offline Offline
Posting Whiz

Re: TO CHAINSAW - or anybody else who knows C++

 
0
  #21
Aug 17th, 2004
Sorry, here's a better font:

#define MAX(x,y) (
if(x>y)delete(y)
else if((y)>(x))delete(x)
)
Reply With Quote Quick reply to this message  
Join Date: Aug 2004
Posts: 153
Reputation: cosi is an unknown quantity at this point 
Solved Threads: 1
cosi's Avatar
cosi cosi is offline Offline
Junior Poster

Re: TO CHAINSAW - or anybody else who knows C++

 
0
  #22
Aug 17th, 2004
Chainsaw your code is good. I think you are a fine engineer in the field.

I meant Mr. C++'s code is wrong. He uses * and & with no idea what those operators mean. I've explained it to him more than once in different questions with the same mistakes.

Mr. C++, please don't say that the code people help you with is wrong. At best we spare a few moments of our time to stamp the solution out. For all I care I could be simply giving you pseudocode that doesn't compile in a compiler at all. The code is meant to illustrate a concept. It is your job to understand and learn the concepts. You should be able to rewrite the code you find here on your own.


Ed

Originally Posted by Chainsaw
C++, you posed the question as:
COSI - were you saying my code was wrong? What was wrong with it? You said something about pointers and dereferencing; can you enlighten me?
Reply With Quote Quick reply to this message  
Join Date: Aug 2004
Posts: 153
Reputation: cosi is an unknown quantity at this point 
Solved Threads: 1
cosi's Avatar
cosi cosi is offline Offline
Junior Poster

Re: TO CHAINSAW - or anybody else who knows C++

 
0
  #23
Aug 17th, 2004
Ok... I still have the stomach to answer your question. This time at least it's a different mistake ;-)

#define's can only be multilined if you do the \
at the end of the line

  1. #define MAX(x,y) \
  2. if(x>y)delete(y) \
  3. else if((y)>(x))delete(x)

This is in contrast to inline functions that can be multilined without the \

  1. inline int max(x,y) {
  2. if (x>=y)
  3. return x;
  4. else return y;
  5. }


You asked about the conditional?
Here's how to use a conditional:
boolean-condition ? statement-to-excute-if-true : statement-to-execute-if-false;

This time, try to come up with the code to do it on your own. Won't spoon feed you this time.


Ed


Originally Posted by C++
Sorry, here's a better font:

#define MAX(x,y) (
if(x>y)delete(y)
else if((y)>(x))delete(x)
)
Reply With Quote Quick reply to this message  
Join Date: Jun 2004
Posts: 436
Reputation: Chainsaw is an unknown quantity at this point 
Solved Threads: 10
Chainsaw's Avatar
Chainsaw Chainsaw is offline Offline
Unprevaricator

Re: TO CHAINSAW - or anybody else who knows C++

 
0
  #24
Aug 17th, 2004
C++ why are you deleteing x or y? You said:
"Define a macro MAX that accepts two parametersª and expands to the valueª of the largerª of the two (you'll need the conditionalª operatorª for this). "

where does it say you want to delete x or y? And, when you "expand to a value" it isn't an if statement, thats why they say you'll need a conditional.

By the way, what certification IS this? Sounds like a class C++ test.
Reply With Quote Quick reply to this message  
Join Date: Aug 2004
Posts: 350
Reputation: Ghost is an unknown quantity at this point 
Solved Threads: 2
Ghost's Avatar
Ghost Ghost is offline Offline
Posting Whiz

Re: TO CHAINSAW - or anybody else who knows C++

 
0
  #25
Aug 17th, 2004
It is Turingscraft C++ certification.
Reply With Quote Quick reply to this message  
Join Date: Aug 2004
Posts: 153
Reputation: cosi is an unknown quantity at this point 
Solved Threads: 1
cosi's Avatar
cosi cosi is offline Offline
Junior Poster

Re: TO CHAINSAW - or anybody else who knows C++

 
0
  #26
Aug 17th, 2004
Ah... It all makes sense now. I never did have much faith in certification programs. Best certification is demonstrated project experience. :-)


Originally Posted by C++
It is Turingscraft C++ certification.
Reply With Quote Quick reply to this message  
Join Date: Aug 2004
Posts: 153
Reputation: cosi is an unknown quantity at this point 
Solved Threads: 1
cosi's Avatar
cosi cosi is offline Offline
Junior Poster

Re: TO CHAINSAW - or anybody else who knows C++

 
0
  #27
Aug 17th, 2004
If this is truly a C++ test, why the focus on so much C style code?
Reply With Quote Quick reply to this message  
Join Date: Aug 2004
Posts: 350
Reputation: Ghost is an unknown quantity at this point 
Solved Threads: 2
Ghost's Avatar
Ghost Ghost is offline Offline
Posting Whiz

Re: TO CHAINSAW - or anybody else who knows C++

 
0
  #28
Aug 17th, 2004
Good question - and that's why I need your help. I know C++, but not C.
Reply With Quote Quick reply to this message  
Join Date: Aug 2004
Posts: 350
Reputation: Ghost is an unknown quantity at this point 
Solved Threads: 2
Ghost's Avatar
Ghost Ghost is offline Offline
Posting Whiz

Re: TO CHAINSAW - or anybody else who knows C++

 
0
  #29
Aug 19th, 2004
Hi everybody,

thanls for all your help. I just completed the C++ certification.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum


Views: 5475 | Replies: 28
Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC