I don't quite understand what you are asking? But I will make a guess. You are saying that a class containing since int will have objects of size 4 bytes. Then why does empty class takes 1 byte instead of 4 bytes? Because 1 byte is enough for the purpose of differentiating two objects of an empty class. So why use 4 bytes and waste 3 bytes per object?
class objects have to have non zero memory size.
In case of class A it is empty since compiler cant determinne the size it will allocate minimum allocation unit i.e. 1 byte for its object.
In case of class B it has int variable so compiler knows its size and hence will allocate appropriate size i.e 4 bytes for int for its object.
The problem I have is that when the cursor is at the top of the client window and I click the right mouse button, the value of point.y is around 72 instead of zero. When I use this same code in the OnLeftMouseDown routine, the value of point.y at the top of the Client window is zero.
Because OnContextMenu point parameter is in screen co-ordinates and your right click handler point is in client co-ordinates so call ClientToScreen/MapWindowPoints to convert to screen co-ordinates. That's why it's zero in right click handler and 72 in context menu handler.
From MSDN for OnContextMenu point parameter
Position of the cursor, in screen coordinates, at the time of the mouse click.
From MSDN for OnLButtonDown point parameter
Specifies the x- and y-coordinate of the cursor. These coordinates are always relative to the upper-left corner of the window.
Microsoft MVP for VC++
Code must be written to be read, not by the compiler, but by another human being.
The most important issues deals with template and partial specialization.
Pay special attention to the use of the typename keyword, and to the way parameter lists are declared while reusing template declarations, since some scope rule are different.
My problem is this:
I have two different projects, one dependent on the other. The first project compiles to produce a static lib. It also includes a namespace, let's call it "NAM" for the purpose of this question. The second project then includes the headers from the first project, and the static lib in its settings.
This all seems fine, and the first project (the lib) compiles with no problems. However when I compile the second project, I receive linker errors for all of the namespace functions called in the first project's single .cpp file. So for instance, in project 1, I might have the function:
Which compiles just fine when I compile that project alone. But in the second project, I get this weird linker error that says:
error LNK2001: unresolved external symbol _Find_String
What am I doing wrong? It's like somehow the second project doesn't see the 'namespace' declared in the first project even though all the headers (there are only 3) are included and the lib is linked correctly.
Please check whether you have properly included the staticlib in its settings. Second thing, you have to specify the path in which the static liv is located in Project->Settings->Link->Input. Also please check whether you have included the namespace of the first project in the second one.
Your thread is an infinite loop, so it's probably eating up all the time there. I don't see where you end your thread, as it can't end itself.
You could put a
in your thread, and you'll see the usage drop.
In reality a useful thread would probably be performing some function and then suspending itself until it's time to do that function again. While it's working, it'll use whatever CPU time it needs to complete the task.