|
How can I simplify this:
grid[x][y] == 0 ? grid[x][y] = 1 : grid[x][y] = 0;
I was thinking that I could make a pointer (or address) to that part of the array, then like shift the bits or something (each part of the array is a BYTE), but I couln't figure out how to do it.
Any ideas? thanks
|
|
|
|
|
grid[x][y] == 0 ? grid[x][y] = 1 : grid[x][y] = 0; means basicly :
<font color=#0000FF>if</font> (grid[x][y] == 0) {
grid[x][y] = 1;
}
<font color=#0000FF>else</font> {
grid[x][y] = 0;
}
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Oh, yeah, I wasn't talking simplifying like that, I meant something like
BYTE GridPos = &grid[x][y];//might not even need this
GridPos &= GridPos;
(I know thats wrong, but thats what I'm thinking it should look like, just diffrent opperators)
|
|
|
|
|
don't ... it looks ugly, it's unreadable ...
I suggest keeping it as simple as possible and let the compiler do the work for you.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
ok,
if we consider the test (== 0 ) MUST be performed befor doing anything on the matrix, the code is not very "simplifying".
if not, i consider that, if grid[x][y] equal 0, it must be set to 1, and if it equals 1, it must be set to 0. it is then easy to do that with the bitwise not ~= operator :
grid[x][y] ~= grid[x][y];
according to the table :
~ 1 0
-------
= 0 1
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
I'm not sure what is non-simple about what you already have, but this is an alternative:
grid[x][y] = ! grid[x][y];
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
|
hi everyone...
i have this little problem and i hope u can help me with it..
the problem appears when using the following code:
Graphics* pGraphics = new Graphics(hdc);
the previous code doesn't compile:
error C2660: 'Gdiplus::GdiplusBase::operator new' : function does not take 3 parameters
|
|
|
|
|
Did you miss the #define new DEBUG_NEW statement at the top of your .cpp file? To squelch the compiler error, simply undefine the new operator prior to including gdiplus.h .
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Or you could use ::new for GDI+ objects. That way you do not loss the DEBUG_NEW functionality in the rest of your code.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it!
|
|
|
|
|
Doh! Thanks for reminding me of the scope-resolution operator.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
i undefined new and everything went OK...but what's the functionality of DEBUG_NEW anyway..
|
|
|
|
|
saeedmalas wrote:
what's the functionality of DEBUG_NEW anyway
It implements the ability of the debugger to be able to track the line number and file name of where any memory leaks were allocated.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_mfc_debug_new.asp[^]
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it!
|
|
|
|
|
|
I beleave that this will do everything you need.
#pragma push_macro("new")
#undef new
#include <gdiplus.h>
#pragma pop_macro("new")
Thank You
Bo Hunter
|
|
|
|
|
i tried the push_macro but it didn't work!!!i think this is because the "new" in my code should be altered..
|
|
|
|
|
Hi again,
How to set the TAB ORDER of a control in runtime manually?
Can anyone help me plz?
Ivan Cachicatari
www.latindevelopers.com
|
|
|
|
|
in the dialog editor, Ctrl+D ("change the Tab order"), then reorganize...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
|
|
Use SetWindowPos() .
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Ivan Cachicatari wrote:
How to set the TAB ORDER of a control in runtime manually?
The tab order is simply the Z-order of the windows, so to change it use SetWindowPos() as David suggested.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Hi everyone,
I have a problem with hiding the vertical and horizontal scroll bars of the CHtmlView in a CFrameWnd or CDialog.
How to do it?
I did try with this code in CMyHtmlView::PeeCreateWindow function
cs.dwExStyle &= ~WS_EX_CLIENTEDGE;
cs.dwExStyle &= ~WS_EX_RIGHTSCROLLBAR;
cs.style &= ~WS_BORDER;
cs.style &= ~WS_VSCROLL;
return CHtmlView::PreCreateWindow(cs);
but it does not work!
Ivan Cachicatari
www.latindevelopers.com
|
|
|
|
|
I Am working on a win2000 pro and i want my app to the same interface as of the win xp luna theme what can i do to give my app the look of xp theme.
i have seen some programs which have the same look and feel as the xp theme wheter they are on xp ,2000, 9x, or me
|
|
|
|
|
When it doubt consult MSDN[^]
|
|
|
|