I had a little argument, and was wondering what people out there think:
In C++ (or in general), do you prefer code broken up into many shorter functions, with main() consisting of just a list of functions, in a logical order, or do you prefer functions only when necessary (i.e., when they will be reused very many times)? Or perhaps som...
I need to code a class that recieves a collection with any number of elements of any 'primitive' type. I also need to be able to know the type of each member (or at least the size of the type).
The purpose of this class is to serialize the elements to store them in a file in fixed length registers.
Is this posible?
I know that C++ is s...
I need to know the root cause of the segmentation fault and also can anyone tell me how to handle it.
...
Hello!
I have a project that builds with CMake system, and I like to import it in Eclipse.
However, when I generate eclipse project files with 'cmake -G "Eclipse CDT4 - Unix Makefiles"'
there are no default include paths in Eclipse project(such as /usr/include' or the gcc path for standard headers).
How to fix that in most right way?
...
So I'm using libsvn on windows in a C++ application. I have several svn trees with which I'm using the api. I assume the whole initialization and setup is correct since all other operations work as expected.
I use svn_client_log4 (also tried svn_client_log with exactly the same results) and usually when my callback is called, I get the ...
Ok, so I know portability is not the strong point of C++, but I have to get my code running on both Mac&Windows. I've come up with a solution, but it's not perfect, and I'm interested to see if there is someone out there who can suggest a better one.
I need to us a class hierarchy in several DLLs/bundles - e.g., I have an abstract base ...
Is following code legal C++ or not?
class Foo
{
class Bar;
void HaveADrink(Bar &bar);
void PayForDrinks(Bar &bar);
public:
void VisitABar(int drinks);
};
class Foo::Bar
{
public:
int countDrinks;
};
void Foo::HaveADrink(Bar &bar)
{
bar.countDrinks++;
}
void Foo::PayForDrinks(Bar &bar)
{
bar.countDrinks = 0;
}
void ...
I'm fairly noobish at C++, but very comfortable with pointers, dereferencing, etc. I'm having a problem with my overload of the << operator for a class, in that it compiles fine but crashes when run. It feels like an infinite loop, but I'm not certain. Here's the code, and any help is appreciated.
#include <string>
#include <iostream>
...
What OpenGL / GLUT reference is the best around?
Ideally I'm looking for something with C++ sample code to help me learn OpenGL as well as details about the APIs similar to what MSDN provides for .net programming.
If there isn't a one stop shop, then please list the set of references I should use and what the strengths of each one is.
...
I am getting a lot of these warnings from 3rd party code that I cannot modify.
Is there a way to disable this warning or at least disable it for certain areas (like #pragma push/pop in VC++)?
Example:
list.h:1122: warning: `list<LogOutput*, allocator<LogOutput*> >::node_alloc_' will be initialized after
list.h:1117: warning: `alloca...
it works when :
list<ItemFixed> XYZ::List()
{
list<Item> items = _Browser->GetMusic();
list<ItemFixed> retItems = _Converter->Convert (items);
return retItems;
}
but not :
list<ItemFixed> XYZ::List()
{
return _Converter->Convert (_Browser->GetMusic());
}
Any suggestions?
thanks
...
Having been tainted by Linq, I'm reluctant to give it up. However, for some things I just need to use C++.
The real strength of linq as a linq-consumer (i.e. to me) lies not in expression trees (which are complex to manipulate), but the ease with which I can mix and match various functions. Do the equivalents of .Where, .Select and ....
i try to play a music file in my coding, but failed. i have my music file in the same folder which save .cpp file.
can someone help me?
my code is:
#include <iostream>
#include <windows.h>
int main() {
PlaySound("kenny g.WAV", NULL, SND_ASYNC);
}
...
I've read the article about scope guards (Generic: Change the Way You Write Exception-Safe Code — Forever) in DDJ and I understand their common use.
However, the common use is to instantiate a particular stack guard on the stack for a particular operation, e.g.:
{
FILE* topSecret = fopen("cia.txt");
ON_BLOCK_EXIT(std::fclose, t...
hi
i wrote a face & eye detection code
next step is put an image to the coordinates of the detected eye (for ex: eye
patch, eye glasses)
i couldn't find the function to combine the source frame and the image I want to add
any suggestions
thanks
...
Hi
I have following basic questions :
When we should involve disassembly in debugging
How to interpret disassembly, For example below what does each segment stands for
00637CE3 8B 55 08 mov edx,dword ptr [arItem]
00637CE6 52 push edx
00637CE7 6A 00 push 0...
Why is it not allowed to get non-const reference to a temporary object,
which function getx() returns? Clearly, this is prohibited by C++ Standard
but I am interested in the purpose of such restriction, not a reference to the standard.
struct X
{
X& ref() { return *this; }
};
X getx() { return X();}
void g(X & x) {}
int f(...
In my game code, I process key input by handling WM-KEYDOWN message.
wParam gives me the keycode i need.
The problem is with IME, especially KoreanIME.
I get WM-IME-COMPOSITION and then WM-KEYUP, but never the WM-KEYDOWN.
So, the bottom line is.. I need to get keycode when i receive WM-IME-COMPOSITION.
Is there a way to do so?
Any hel...
How to get the unique number (serial number/ID) for Processor (CPU), SCSI, Display, and IDE using C++ program other than WMI and asm code?
...
Hi folks,
I know that i can use QSignalMapper to call a slot with different parameters based on connection. What i want to achieve is a little different.
We are using plugins in our application and different plugins are responsible for different types of objects. We are connecting multiple slots, each implemented in a different plugin,...