Is there any advantage over using a class over a struct in cases such as these?
(note: it will only hold variables, there will never be functions)
class Foo {
private:
struct Pos { int x, y, z };
public:
Pos Position;
};
Versus:
struct Foo {
struct Pos { int x, y, z } Pos;
};
Similar questions:
http://stackov...
Hi all,
I am trying to build a vertical explorer bar (band object) in IE7 that "sticks" across all tabs (similar to the "Favorites" bar).
In case you don't know I'm talking about, open up IE7 and go to View->Explorer Bar->Research to open the Research bar. Open a new tab in the same window and notice that the research bar is not displa...
Hello, how expensive is it to perform the dereference operation on a pointer in C++? I can imagine that the memory transfer is somehow proportional to the object size, but I want to know how expensive the dereference operation part is.
Thank you.
...
::GetSystemMetrics (SM_CYBORDER)
...comes back with 1 and I know the title bar is taller than ONE pixel :/
I also tried:
RECT r;
r.left = r.top = 0; r.right = r.bottom = 400;
::AdjustWindowRect (
_bdW = (uword)(r.right - r.left - 400);
_bdH = (uword)(r.bottom - r.top - 400);
But border w,h cam...
For my current project I want to be able to load some classes from a dll (which is not always the same, and may not even exist when my app is compiled). There may also be several alternative dll's for a given class (eg an implementation for Direct3D9 and one for OpenGL), but only one of the dlls will be loaded/used at any one time.
I ha...
How would you go about determining whether a position is already occupied or not? When the memory is allocated, all that there is in it is garbage (in C++, which is what I'm using atm). I was thinking of using an auxiliary array of bools to know whether the position is occupied, but that would demand quite a lot of additional memory.
I ...
Hello,
would anyone know of a class/example application for a message only window that is in c++ win32?
Thank you Micheal Weller! I took the code for a standard window in c++ and commented out the show window and it works like a charm! Thanks again!
...
In a C++ physics simulation, I have a class called Circle, and Square. These are Shapes, and have a method called push(), which applies force to it. There is then a special case of Circle, call it SpecialCircle, in which push() should exhibit slightly different properties. But in fact, there is also SpecialSquare() which should exhibit...
Consider the following:
int ival = 1.01;
int &rval = 1.01; // error: non-const reference to a const value.
int &rval = ival;
rval = 1.01;
The first assignment of &rval to a literal value fails as expected. If I comment out that line the code compiles and runs. I understand why the initialization fails, but I'm confused why the assi...
I always work in windows environment and most often to write the program in C/C++.
Is it necessary to a Windows Application Programmer to remember Win32 APIs as more
as possible??
Dazza
...
I learned today that there are digraphs in C99 and C++. The following is a valid program:
%:include <stdio.h>
%:ifndef BUFSIZE
%:define BUFSIZE 512
%:endif
void copy(char d<::>, const char s<::>, int len)
<%
while (len-- >= 0)
<%
d<:len:> = s<:len:>;
%>
%>
My question is: why do they exist?
...
Is there a O(1) way in windows API to concatenate 2 files?
O(1) with respect to not having to read in the entire second file and write it out to the file you want to append to. So as opposed to O(n) bytes processed.
I think this should be possible at the file system driver level, and I don't think there is a user mode API available ...
Debugging with gdb, any c++ code that uses STL/boost is still a nightmare. Anyone who has used gdb with STL knows this. For example, see sample runs of some debugging sessions in code here.
I am trying to reduce the pain by collecting tips. Can you please comment on the tips I have collected below (particularly which ones you have been...
How can you get a user token from Logonuser for a user account with no password?
In particular Logonuser will fail for accounts that do not have passwords.
You can validate an account by checking for a blank password + checking for GetLastError() == ERROR_ACCOUNT_RESTRICTION.
But I need to actually get a token returned, so I need thi...
Could you please explain me, what is the different between API functions AllocConsole and AttachConsole(-1) ? I mean if AttachConsole gets ATTACH_PARENT_PROCESS(DWORD)-1
Update: Sorry! My mistake. Of course AllocConsole instead of CreateConsole!
...
I have a very large app, 1.5 million lines of C++, which is currently MFC based using the Document/View architecture. The application includes a lot of 3d vector graphics, spreadsheets, and very many dialogs and Windows. Within the constraints of the DVA it is fairly well written, in that there is no significant program logic in the us...
Please consider the following scenario:
map(T,S*) //Forward decleration
map(T, S*) T2pS = GetMap();
for(map(T, S*)::iterator it = T2pS.begin(); it != T2pS.end(); ++it)
{
if(it->second != NULL)
{
delete it->second;
it->second = NULL;
}
T2pS.erase(it);
//In VS2005, after the erase, we will crash on ...
Hello, I have a question concerning this code which I want to run on QNX:
class ConcreteThread : public Thread
{
public:
ConcreteThread(int test)
{
testNumber = test;
}
void *start_routine()
{
for(int i = 0; i < 10; i++)
{
sleep(1);
cout << testNumber << endl;
}
}
private:
...
I've run into a really strange bug, that I'm hoping someone can explain. I have a simple std::vector<V3x>, where V3x is a 3d vector (the linear algebra kind.) The following code causes a std::length_error exception to be thrown:
std::vector<V3x> vertices;
int vertexCount = computeVertexCount();
vertices.resize(vertexCount); // throws st...
I went in late in a project of gamedev of a simple text game in C++.I studied the project and I think I know how to do everything but i get stuck on a thing:how to save and load the game as proposed.I don't want to have the thing done for me,only you show me a way to do it.
...