Is there a method/pattern/library to do something like that (in pseudo-code):
task_queue.push_back(ObjectType object1, method1);
task_queue.push_back(OtherObjectType object2, method2);
so that I could do the something like:
for(int i=0; i<task_queue.size(); i++) {
task_queue[i].object -> method();
}
so that it would call:
obj1...
I want to be able to determine the output folder based on the platform name: AS3, AS4, AS5, SUN.
I couldn't figure out how to extract the platform name from the system. I experimented with:
uname -a
file /bin/bash
Thanks
Solution
./lsb_release -a
Kudos to Paul Dixon
...
What is the memory overhead of having an empty vector vs having a pointer to a vector?
Option A:
std::vector<int> v;
Option B:
std::vector<int> *v = NULL;
I believe that option B takes 1 32 bit pointer (assuming 32 bit here)
How much memory does the empty 'v' take up?
...
New guy want to learn about socket programming in win32. I know bit of MFC but thats not good point to start as it just hides the internal details form programmer.
...
Ok, I understand what is static variable is, but what is a "static" function?
And why is it that if I declare function let's say "void print_matrix" in let's say a.cpp (WITHOUT a.hpp) and include "a.cpp" - I get "print_matrix@@....) already defined in a.obj", BUT if I declare it "static void print_matrix" then it compiles?
UPDATE Just...
A previous question showed a nice way of printing to a string. The answer involved va_copy:
std::string format (const char *fmt, ...);
{
va_list ap;
va_start (ap, fmt);
std::string buf = vformat (fmt, ap);
va_end (ap);
return buf;
}
std::string vformat (const char *fmt, va_list ap)
{
// Allocate a buffer on the stack...
I have to import/translate the code from one C++ class so that I may use it in a C program.
The C program is large and has lots of dependencies on C libraries both open and closed.
The C++ Class .cpp file is 650 lines
I have no experience mixing C and C++ so even though I have looked at one guide on how to do it, I am not convinced wh...
Hi,
I am trying to debug a small operating system I have written in an university course in C++. At runtime somewhere one of my objects is getting corrupted. It seems like this happens due to accidentally writing to the wrong memory address. As I am unable to find the place where this happens from pure looking at the code, I need anothe...
There are some very good books about Lua. What they cannot cover is the big picture, when it comes to real applications (doc/view-type of applications). The interesting things are around those questions:
Use C++ in Lua or Lua in C++?
Who gets the main-loop?
What plays where?
How are model (document) and Lua-State kept in sync? Should t...
When ClickOnce deploys apps, it generates an .application file that allows you to execute the application, so the main application is builded on C++.Net 2003 using Fx1.1, when I told him that call the first file (.application file from ClickOnce Deployment C# 3.0 app) he didnt know how ¿?!
I trying to write some code snippet, the code b...
Duplicate of this question.
I'm learning C++ at the moment, and I'm coming across a lot of null-terminated strings. This has got me thinking, what makes more sense when declaring pointers:
char* string
or
char *string
? To me, the char* format makes more sense, because the type of "string" is a pointer to a char, rather than a cha...
I am experimenting with C++ winsockets. I want to create a method with which I can find the server on the network, without knowing it's IP. To do this I simply loop my connect method through IP adresses 192.168.1.0 to 192.168.1.255. However, the time between each connect is quite large, the program tends to wait at the: connect(nBytes, (...
The other week, I wrote a little thread class and a one-way message pipe to allow communication between threads (two pipes per thread, obviously, for bidirectional communication). Everything worked fine on my Athlon 64 X2, but I was wondering if I'd run into any problems if both threads were looking at the same variable and the local ca...
I am interested in writing a very minimalistic compiler.
I want to write a small piece of software (in C/C++) that fulfills the following criteria:
output in ELF format (*nix)
input is a single textfile
C-like grammar and syntax
no linker
no preprocessor
very small (max. 1-2 KLOC)
Language features:
native data types: char, int an...
i am trying to compile my program which uses regex on linux. I built the boost library in the
libs/regex/build
by typing
make -fgcc.mak
which created a directory gcc which contains the following four files
boost_regex-gcc-1_35
boost_regex-gcc-d-1_35
libboost_regex-gcc-1_35.a
libboost_regex-gcc-d-1_35.a
Now I want to use regex ...
Hello,
Many times when I am watching others code I just want to find where and how a variable is defined. Normally what I do now is look for the type of the variable until I find the definition, that is very time consuming. And I guess that there are some tools that can help me in this rutinary situation. Any suggestion in some tools or...
I recently added some DirectX code to my program, and now my double data type variables only have the range/resolution of a float (.. or atleast less range/resolution than they used to). If I remove the direct3D initialization - "Direct3DCreate9(D3D_SDK_VERSION)" - the problem goes away. Any insight? Thanks.
...
Firstly, I'm pretty new to C++. I believe that getline() isn't a standard C function, so #define _GNU_SOURCE is required to use it. I'm now using C++ and g++ tells me that _GNU_SOURCE is already defined:
$ g++ -Wall -Werror parser.cpp
parser.cpp:1:1: error: "_GNU_SOURCE" redefined
<command-line>: error: this is the location of the previ...
Hi All,
We are using the CString class throughout most of our code. However sometimes we need to convert to a char *. at the moment we have been doing this using variable.GetBuffer(0) and this seems to work ( this mainly happens when passing the Csting into a function where the function requires a char *). The function accepts this and ...
Background
I have an abstract class, something like
class IConverter{
public:
virtual void DoConvertion() = 0;
};
There will be many concrete classes which just implements DoConvertion method.
class TextConverter : public IConverter{
public:
virtual void DoConvertion(){
// my code goes here
}
};
class ...