| | |
TO CHAINSAW - or anybody else who knows C++
Please support our C++ advertiser: Programming Forums - DaniWeb Sister Site
![]() |
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
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?
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
This is in contrast to inline functions that can be multilined without the \
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
#define's can only be multilined if you do the \
at the end of the line
C++ Syntax (Toggle Plain Text)
#define MAX(x,y) \ if(x>y)delete(y) \ else if((y)>(x))delete(x)
This is in contrast to inline functions that can be multilined without the \
C++ Syntax (Toggle Plain Text)
inline int max(x,y) { if (x>=y) return x; else return y; }
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)
)
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.
"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.
![]() |
Similar Threads
- free() = delete or delete[]? (C++)
- Forum lurkers, introduce yourself ... !! (Community Introductions)
- Recursive prime number f(x) (C)
- passing objects as arguments (C++)
Other Threads in the C++ Forum
- Previous Thread: ive got a Q
- Next Thread: how to start out
Views: 5475 | Replies: 28
| Thread Tools | Search this Thread |
Tag cloud for C++
6 add api array arrays assignment beginner binary bitmap c++ c/c++ calculator char class classes code compile compiler console conversion convert count data database delete desktop developer directshow dll encryption error file forms fstream function functions game generator getline givemetehcodez graph homeworkhelper iamthwee ifstream input int integer java lazy lib linux loop looping loops map math matrix memory multidimensional newbie news node number output parameter pointer problem program programming project proxy python random read recursion recursive reference return sort string strings struct studio system template templates text tree url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets





