|
Macros are there to make your life simple and your code easy to read. Take the following example:
#define min(x,y) (x<=y?x:y)
int a = 10;
int b = 20;
cout << min(a,b);
Since you created a macro your code has instantly become easier to read and write. When you hit the 'compile' button, before the compiler does anything it will go through all your code and replace the macros with the real code, from the above example the compiler will produce
cout << 10<=20?10:20;
Other types of macros go alongside functions. Take the CreateWindow() function for example. This is actually a macro, there are two versions of the real function CreateWindowA() and CreateWindowW() each taking ansi strings and unicode strings. That's where the _UNICODE macro comes in:
#if defined _UNICODE
#define CreateWindow CreateWindowW
#else
#define CreateWindow CreateWindowA
#endif
So now anytime you use the CreateWindow macro, that macro will be replaced with the real function name depending on whether or not your project is unicode.
|
|
|
|
|
Thank you very much.
I understood it.
|
|
|
|
|
WalderMort wrote: #define min(x,y) (x<=y?x:y)
be careful with this, and prefer defining it as below. read my other post also to have a relevant explanation of this :
#define min(x,y) ((x)<(y) ? (x) : (y))
ps:here, the spaces are not necessary, but add them because : ( gives me a smiley otherwise...
|
|
|
|
|
what WalderMort doesn't say, is that your life can become a nightmare if you come to debug your SUM() macro:
#define SUM(a,b,c) a + b + c
when you define a macro, your first reflex should be to worry about operators precedence. Here is an exemple:
float f = SUM(2, 2, 2) * 5;
you're expecting f to be 30 (6 * 5), right ?
but here is how the compiler treats your macro expansion:
float f = 2 + 2 + 2 * 5;
and as you propably know, multiplication operator is more prioritary over addition, so f actually gets :
float f = 2 + 2 + (2 * 5);
so don't forget parenthesis when defining macros, ever !!!
#define SUM(a,b,c) <code>(</code>a + b + c<code>)</code>
|
|
|
|
|
Hi,
I wish to remove the title bar of the window...It is created with CreateWindowEx. If possible, could you tell the procedure...
Regards,
nag.
|
|
|
|
|
You can create the window without the caption by using the appropriate window style(s).
To remove a caption later you'd need to change the window's style.
See SetWindowLongPtr Function[^] for how to change a window's style.
Mark
"Great job, team. Head back to base for debriefing and cocktails."
(Spottswoode "Team America")
|
|
|
|
|
HI all
Is there anu Microsoft Certification for VC++.
Tell is ther any certification for C++ which is worth full to put in resume
VIBIN
"Fool's run away,where angle's fear to tread"
|
|
|
|
|
why bother? Having a certificate doesn't prove you are a good programer it just proves you can pass a test.
In your resume, add details of projects/libraries you have completed and possibly even give a demo.
|
|
|
|
|
Certifications in C++ are of zero value. Certifications in, e.g., .NET, such as MCTS, can be of some value - i.e., some employers insist on them and/or value them as an added bonus to requisite commercial experience.
Kevin
|
|
|
|
|
Hi all
which one is better and why ?
I have heard like Visual C++ is far better than C++.net but at the same time its quite difficult.
So does any body have good link to learn about VC++.
I knw how to program over C++.NET but i am new over VC++..
Please guide me the right path.
Thanks a lot
|
|
|
|
|
|
I am assuming that Visual C++ is ISO C++ (with some Microsoft only features) and C++.NET is Managed C++ or "C++/CLI". I wouldn't say one is better than the other. Visual C++ can be used for low-level programming with high-level abstraction; thus, Visul C++ is powerful. IMHO, C++/CLI is (at this time) more of a bridge language between native code and managed code.
Nevertheless, you can learn Visual C++ from any book that covers ISO C++:
C++ Programming Language, Bjarne Stroustrup, ISBN: 0-201-88954-4
Ivor Horton's Beginning Visual C++ 2005, Ivor Horton, ISBN: 0-7645-7197-4
http://www.intap.net/~drw/cpp/[^]
http://www.mycplus.com/[^]
http://www.fredosaurus.com/notes-cpp/[^]
Use Google to find books and e-books!
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
|
Pan San wrote: 没有更好,只有看哪个更适合你
you seem to have a serious problem with english, don't you ?!
|
|
|
|
|
Hey, the negativity ("-") just got onto you!
Press: 1500 to 2,200 messages in just 6 days? How's that possible sir?
Dr.Brad :Well,I just replied to everything Graus did and then argued with Negus for a bit.
|
|
|
|
|
Bob's math coprocessor has some serious problems
Press: 1500 to 2,200 messages in just 6 days? How's that possible sir?
Dr.Brad :Well,I just replied to everything Graus did and then argued with Negus for a bit.
|
|
|
|
|
toxcct wrote: Pan San wrote:
没有更好,只有看哪个更适合你
you seem to have a serious problem with english, don't you ?!
toxcct,
The poster said (according to http://www.worldlingo.com/[^]), "Not better, only then looked which suits you."
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
I think you are a clever boy!
My English is really poor,although I have studied English 13 years ,but I found it have no effect to me.
Sorry to say,I haven't pass the CET6 exam,by the way ,I'm a Master of computer,I still should to study English,it's boring.when I want to find some technique articles,it's hard for me to read English articles.
From this sentence I have wrote,you can sure my English is so poor,isn't it?
But you should know,I'm not a person who come from Europe or other country which said English.I think you had know where I from,lukily to say ,I come from a great and beautiful country.
|
|
|
|
|
Software_Specialist wrote: which one is better and why ?
What is better, a fork or a spoon ? I guess it depends on the task at hand.
Software_Specialist wrote: I knw how to program over C++.NET but i am new over VC++..
How do you mean ? C++.NET is standard C++, with .NET extensions. If you know C++.NET, you know at least some C++.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Then for what tasks C++.NET is better and for which tasks VC++ is better.
Dont you think VC++ is lot more complicated than C++.NET ?
And if not then give me a simple windows based application example, explaining how you would achieve in both.
Obviously i know C++ but on .NET platform. So i am keen to know which is better and what industry needs more these days ...
|
|
|
|
|
Clickety[^]
Press: 1500 to 2,200 messages in just 6 days? How's that possible sir?
Dr.Brad :Well,I just replied to everything Graus did and then argued with Negus for a bit.
|
|
|
|
|
What do you need exactly?
|
|
|
|
|
Hi all.
I write code:
<br />
CStringArray a1,a2;<br />
. . . . .<br />
. . . . . <br />
for(int i=0; i < a1.GetSize(); i++)<br />
a2.Add(a1.GetAt(i));<br />
<br />
a2.RemoveAt(Sel);
a2.FreeExtra();<br />
<br />
if(a1.GetUpperBound() == a2.GetUpperBound())<br />
return;
My progrum tell me that this string are equal.
Can help?
|
|
|
|
|
david bagaturia wrote: if(a1.GetUpperBound() == a2.GetUpperBound())
return;//and it come here
I can see there are no elements in a2 . Probably, there are no elements in a1 ,too. In this case
GetUpperBound returns -1. Which cause equality between these two.
|
|
|
|
|