|
a const object can handled by a member function qualified by const
never say die
|
|
|
|
|
change your prototype into :
matrix operator + (const matrix& toAdd) const
for the same, if you say that the parameter toAdd is const , then toAdd.get_el() will crash if matrix::get_el() is not defined as const member function
TOXCCT >>> GEII power
[VisualCalc 3.0 updated ][Flags Beginner's Guide new! ]
|
|
|
|
|
MALDATA wrote: "passing 'const matrix' as 'this' argument of 'int matrix::get_rows()' discards qualifiers"
Make the get member functions const:
int matrix::get_rows() const<br />
{ ... }
You can only call const methods on a const object.
--Mike--
Visual C++ MVP
LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
|
|
|
|
|
codes here:
//////////////////////////////////////
// fill the screen with pure color
CWindowDC dc(NULL);
CRect rect;
GetWindowRect(&rect);
CBrush br;
br.CreateSolidBrush(RGB(255, 0, 0));
dc.FillRect(&rect);
the problem is :
I want to recover to the status that the screen is not filled , how to recover?
does InvalidateRect can do it ?
why I refresh the desktop, the screen is recovered to the old style?
please give me some help, waiting for answers online!
my Email is : xuwenq88@126.com
Just my interest for these common things
|
|
|
|
|
|
Simply to repaint the desktop use this
::InvalidateRect(0, NULL, TRUE);
nave
|
|
|
|
|
hello everyone!
I have just started learning VC++. Can anyone suggest me a good book for starting with VC++. I know C++ well. I dont have any idea of MFS, SDK etc.
Plz suggest me something,
Thanks,
|
|
|
|
|
I suggest posting this in the VC++/MFC forum. I am certain you'll get a lot of suggestions there.
Would help to know your technical/coding background.
|
|
|
|
|
This is the Visual C++ / MFC forum
|
|
|
|
|
Guess I was the one confused. Thought I was in suggestions at the time.
|
|
|
|
|
|
I'll second that recommendation. Best getting started book on MFC for any level programmer. Problem is it's out of print but worth the price the used copies are going for nowadays.
|
|
|
|
|
Which Book is in out of print, I hope u r not mentioned clearly.
|
|
|
|
|
sach!! wrote: have just started learning VC++. Can anyone suggest me a good book for starting with VC++. I know C++ well. I dont have any idea of MFS, SDK etc.
Learn VC++ in 21 days! good book to start Vc++ step by step!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
In a Grid control (TstringGrid of BC++) when I click on the scroll bar a message box appears and in parallel the scroller scroll down (in win xp os). But in win2000 the Scroller scrolls only after closing the message Box. Can any body tell how to change the behavior in XP so that it works like win2000?
|
|
|
|
|
Hello all! i have been working on a project that has several forms, and one of them must be opened in the second monitor if available, i am a newbie in c++ but is there any way to achieve this?
many might laugh at me because i am different, i laugh at them because they are the same
|
|
|
|
|
Hi,
I am using Visual Studio 2005. I was using some macros in my code. What I found was that I was unable to reference __LINE__ macro. The output of macros was wrong. I have created a sample and following is the code snippet -
#define TMP_THIS_FILE SimpleTrace_cpp<br />
#define TMP_EVAL(_value_) _value_<br />
#define TMP_(Id) TMP_EVAL(TMPFUNC_) ## TMP_EVAL(Id) ## TMP_EVAL(_) ## TMP_EVAL(TMP_THIS_FILE) ## TMP_EVAL(__LINE__)<br />
<br />
#define doTrace TMP_(CALL)
At line number 22 in my CPP file, If I make a call to -
doTrace();
Then the output should be
TMPFUNC_CALL_SimpleTrace_cpp22()
Instead the compiler is generating -
TMPFUNC_CALL_SimpleTrace_cpp()
And I get a compiler error saying
e:\projects\temp\temp\SimpleTrace.cpp(22) : error C3861: 'TMPFUNC_CALL_SimpleTrace_cpp': identifier not found
Any idea whats going wrong with the compiler? Also do I have to add any compiler switches to use __LINE__ in VS 2005?
S o h a i l K a d i w a l a
modified 21-Apr-21 21:01pm.
|
|
|
|
|
After slogging for couple of hours on this problem, I found the cause.
Change the "Debug Information Format" setting on the C/C++ project setting tab. The setting that does not work is "Program Database for Edit and Continue"; the setting that works is "Program Database".
Thanks a lot to people at Decompile.com. The page with information can be found at http://www.decompile.com/cpp/faq/file_and_line_error_string.htm[^]
I battled this problem for past few hours, finally posted on this forum and found the solution myself in next 5 min
Posting the solution here incase it saves time for someone stuck with same problem in future.
Just curios, is this a known problem and documented somewhere?
S o h a i l K a d i w a l a
modified 21-Apr-21 21:01pm.
|
|
|
|
|
I have a SDI application - one CSplitterWnd and two CView derived panes, top and bottom. We all know that top pane remains "docked" and bottom pane's size changes while resizing main window. I need exactly the opposite: the top pane's size has to change and the bottom pane's height must remain fixed while resizing main window (just like there was a docked control bar at the bottom of the main window). Is this possible (and how)?
--
Vladimir Svrkota,
CardWare
Novi Sad, Serbia.
|
|
|
|
|
overload CMainFrm::OnSize(), you can do what ever you want to do there.
|
|
|
|
|
Thanks, LeeeNN
--
Vladimir Svrkota,
CardWare
Novi Sad, Serbia.
|
|
|
|
|
I'm trying to send and receive data using overlapped sockets and completion routines. Everything works fine, except that quite often the final WSARecv doesn't complete until after some kind of (VERY LONG) timeout. This is basically what my completion routine functions look like:
void CALLBACK OnReceiveComplete(...)
{
if(cbTransferred == 0)
{
printf("Done.\r\n");
}
else
{
printf("Received %d bytes.\r\n", cbTransferred);
WSARecv(..., &OnReceiveComplete);
}
}
void CALLBACK OnSendComplete(...)
{
printf("Sent %d bytes.\r\n", cbTransferred);
WSARecv(..., &OnReceiveComplete);
}
Obviously there is error checking and other things, but that is the gist of it.
Interestingly it doesn't happen on all attempts. I'm doing a simple HTTP GET, and it ALWAYS "hangs" on "www.google.com", but it NEVER does on "www.cnn.com". Does this have something to do with how the servers are setup, or is there something I can do about this? Right now I just forcefully close the socket if I don't get any response for a certain amount of time. I've seen lots of examples for IOCP and overlapped events, but NONE for overlapped completion routines. I haven't been able to figure out this problem for the longest time, so this is my last-ditch attempt to get an answer.
On a side note, if I use the WinInet functions asynchronously the problem goes away (but there are other issues with using WinInet so I want to avoid it). So obviously there must be some way to know when there is no more data to read. I just can't figure it out.
|
|
|
|
|
I am new to c++. i understand programming i am a advanced vb programmer, but i am just havin problems learning and applying all these new keywords. i am a beginnering in c but i have had experience with the very basic fundamental things.
i am reading through a book and they want me to draw a single bitmap on a client window and have it jump around on the window and not go out of the window boundries. The only thing that happens right now is it just draws it over and over all over the screen without removing the previous instance of the bitmap. THIS IS MY CODE.
void Game_Run()<br />
{<br />
<br />
int x = 0, y = 0;<br />
RECT rect;<br />
GetClientRect(global_hwnd, &rect);<br />
<br />
if (rect.right > 0)<br />
{<br />
x = rand() % (rect.right - rect.left);<br />
y = rand() % (rect.bottom - rect.top);<br />
DrawBitmap(global_hdc, "c.bmp", x, y);<br />
}<br />
}
void DrawBitmap(HDC hdcDest, char *filename, int x, int y)<br />
{<br />
HBITMAP image;<br />
BITMAP bm;<br />
HDC hdcMem;<br />
<br />
image = LoadImage(0,"c.bmp",IMAGE_BITMAP,0,0,LR_LOADFROMFILE);<br />
<br />
GetObject(image, sizeof(BITMAP), &bm);<br />
<br />
hdcMem = CreateCompatibleDC(global_hdc);<br />
SelectObject(hdcMem, image);<br />
<br />
BitBlt(<br />
global_hdc,
x,y,
bm.bmWidth, bm.bmHeight,
hdcMem,
0,0,
SRCCOPY);
<br />
DeleteDC(hdcMem);<br />
DeleteObject((HBITMAP)image);<br />
ShowWindow(global_hwnd, SW_SHOW);<br />
}
all i need it to do is draw once and move around the screen with the rand() function. Any help would be great because this is not a essential task of the book but i like to know how to anything with the language i am learning. THANK YOU.
|
|
|
|
|
to do this, you need to make a copy of the image underneath the bitmap before you draw it. something like this:
1. find out where you want to draw the bitmap
2. make a copy of the background where the bitmap will go to a new bitmap, before you draw there. (create a new bitmap, use BitBlt to copy)
3. when you need to move the bitmap, draw the background copy from step 2 at the place you copied it from. then go to step 1.
to do this smoothly, you'll need to use a double-buffering technique, where you place replace the background and draw the new bitmap in one BitBlt to the main screen. otherwise, you could get a flicker effect.
i think there are articles on CP that discuss how to do double buffering.
Cleek | Image Toolkits | Thumbnail maker
|
|
|
|
|
ok i understand what i need to do but how do i go about making a copy of the background to a bitmap. If i was programming in vb this would take me like 2 seconds but i want to learn c because i have always known and can tell now that its a more powerful language. I appreciate any help thank you.
|
|
|
|