Hi,
Warning this is a long question!
I am implementing a Solitaire card game in C++ on Win32, and after asking this question, it's becoming clear that I may need a bit of guidance regarding actual class design rather than implementation details.
I am using a model view Controller pattern to implement the game. The model is the game, c...
While I am excited that C++0x will be much more fun to program in than C++98, I sometimes feel that some of the new features leave something important to be desired.
For e.g. initializer lists can not be deduced as references to arrays, variadic templates don't allow for member packs or arbitrary expression expansion, local classes can't...
I'm trying to read buffer in C++ one character at the time until '\n', and initialize char array with these characters using do-while loop. I know I could use cin.getline(), but I want to try it on my own.
int main()
{
char buffer [1024];
int index = 0;
char temp;
do
{
cin.get( temp );
buffer [ ind...
Is there any API/way to get the "distance" (called 'hops' in literature) between two NUMA nodes? I want to implement a memory allocation system that takes advantage of this (reuse memory from the nearest node, because the access is faster).
Windows doesn't seem to have such a feature... and libnuma (under Linux) doesn't seem to have it t...
I recently ran into an odd issue where I'd get a const_iterator instead of the expected iterator when iterating through a multiset. It turned out to be a non-issue for MSVC but g++ gave me an error:
error: invalid initialization of
reference of type 'myPtr&' from
expression of type 'const
boost::shared_ptr'
Relevant code:
ty...
hi
I am trying to use type traits to add reference to a template parameter.
template < class T >
struct S {
typename add_reference< T >::type reference; // reference member should always be a reference
};
...
typedef Bar< Foo > type;
S< type > s; // does not add reference, S:: reference is of type type, not type&
However it does not ...
Hello,
I'm using NetBeans for writing some projects.
I declared some methods in my header file, e.g.:
public:
remove(string fileName);
copyIn(string filePath);
copyOut(string fileName);
Is it possible to create stubs of definitions for all of these methods automatically, or do i have to write it manually for each of them?...
Why does each .h file starts with #ifndef #define #endif? We can certainly compile the program without those directives.
...
I have been trying to get the following VB code running in C# for hours now. I keep getting a Value does not fall within the expected range. exception on the CreateStroke() call. Also, here is the Microsoft documentation with a C++ version as well.
Option Explicit
Dim theInkCollector As InkCollector
Private Sub Form_Load()
Set theI...
I've come across cppunit but it didn't look super-easy to use (maybe I didn't look hard, maybe because C++ doesn't work like Java/C#). Are there widely used, simple alternatives?
In fact, is cppunit the standard unit testing framework for C++?
...
Hi
I have some questions about the object size with virtual.
1) virtual function
class A {
public:
int a;
virtual void v();
}
The size of class A is 8bytes....one integer(4 bytes) plus one virtual pointer(4 bytes)
It's clear!
class B: public A{
public:
int b;
virtual void w();
}
What's the...
I will soon be shipping a paid-for static library, and I am wondering if it is possible to build in any form of copy protection to prevent developers copying the library.
Ideally, I would like to prevent the library being linked into an executable at all, if (and only if!) the library has been illegitimately copied onto the developer's ...
I have an application, it uses the libmysqlclient.so
I wonder if I need GPL license on this application due to libmysqlclient be GPL or if I can continue the program in closed source
EDIT:
According to this site, I can use the libmysqlclient in a closed-source software.
Just do not understand why the GPL "infects" the code so much ...
...
A C++ rules engine defines rules in XML where each rule boils down to "if X, then Y" where X is a set of tests and Y a set of actions.
In C++ code, 'functions' usable in tests/actions are created as a class for each 'function', each having a "run(args)" method... each takes its own set of parameters.
This works fine.
But, a separate to...
I have a very simple server/client performance test using boost::asio on Windows and it seems to be performing really poorly. I'm hoping that I'm just using the library incorrectly and would appreciate any advice.
I have a session class that writes a message-length and then writes a message, and then waits to read a message-length and ...
I have a C++ project that has been compiling and linking without problems. Recently we added code to override the global new and delete operators and now the project fails to link with the error: error LNK2005: "void * __cdecl operator new(unsigned int)" (??2@YAPAXI@Z) already defined. I have spent a lot of time googling this problem and...
Dear developers,
I am just curious why drivers and firmwares almost always are written in C or Assembly, and not C++?
I have heard that there is a technical reason for this.
Does anyone know this?
Lots of love,
Louise
...
Hello all :)
I'd like to encapsulate Win32 errors (those returned from GetLastError()) in some form of exception class. Rather than having a single Win32 exception, however, I'd like to be able to have a specialized exception catchable for common errors, such as ERROR_ACCESS_DENIED.
For example, I'd have classes declared like this:
cl...
I'm trying to read in a bitmap starting with its header, but fread is skipping characters for me.
I'm using this typedef in my header:
#include <windows.h> // Used for other
#include <cstdio>
typedef struct tagBITMAPHEADER{
WORD wFileType;
DWORD dwFileSize;
WORD dwReserved;
WORD dwReserved2...
hi
I have gathered a collection of various templates, small utility classes, some obscure domain specific snippets of C++ and python written by me.
was wondering if there is a public domain or open source code repository/dump where the code can be contributed.is there such a thing?
I have source Forge projects, but this files are somew...