I have a C function that contains all the code that will implement the bytecodes of a bytecode interpreter.
I'm wondering if there is a way to align segments of the compiled code in memory on fixed size boundaries so that I could directly calculate the address to jump to from the value of the bytecode? Sort of the same way an array work...
I want to call the base class implementation of a virtual function using a member function pointer.
class Base {
public:
virtual void func() { cout << "base" << endl; }
};
class Derived: public Base {
public:
void func() { cout << "derived" << endl; }
void callFunc()
{
void (Base::*fp)() = &Base::func;
...
I have a custom QT plugin module that has embedded resources. I want to statically link this plugin with an application:
LIBS += -lstatic_plugin_with_resources
In the application I am using the Q_IMPORT_PLUGIN() macro, which allows the application to use the plugin; however the plugin can not access its embedded resources.
Using the...
I have some (C++) functions each containing several calls creating similar arrays of the same basic type on the heap. At various points in these functions, I may need to throw an exception. Keeping track of which arrays have been deleted is a pain, and quite error prone, so I was thinking about just adding the array pointers to a Set<Arr...
I`m writing binary search tree template for two reasons - learning C++ and learning most common algorithms and data structures. So, here is the question - as long as I want to implement iterators, it seems to me that there is no strict definition for where tree ends. What are your suggestions? How do I do this?
...
I'm curious:
If you do a printf("%f", number); what is the precision of the statement? I.e. How many decimal places will show up? Is this compiler dependent?
...
Why is it a problem if we have a huge piece of code between new and delete of a char array.
Example
void this_is_bad() /* You wouldn't believe how often this kind of code can be found */
{
char *p = new char[5]; /* spend some cycles in the memory manager */
/* do some stuff with p */
delete[] p; /* spend some more cycles,...
Possible Duplicate:
Why are references not reseatable in C++
I am trying to more or less swap two reference variables (as practice, I could have swapped the actual variables). I tried doing this by making a temporary variable and making one of the references equal the other, but this got shot down by the compiler. Here is an exa...
What are the advantages of having declarations in a .inl file? When would I need to use the same?
Thanks,
Light
...
Possible Duplicate:
What are the differences between Generics in C# and Java and Templates in C++?
What are the differences between C# generics compared to C++ templates? I understand that they do not solve exactly the same problem, so what are the pros and cons of both?
...
I have an C++ app I built which is registered as the default handler for a file with a specific extension. So when I download one of these files with Firefox from a website, it downloads it to a temp directory and then shell executes my app while passing the full path to the downloaded file on the command line.
What is the best way to ...
I'm on Windows and trying to print an Enhanced Metafile (EMF) using PlayEnhMetaFile().
I'm currently displaying it using a device context for a window on the screen, but now I want to send it to a printer.
How can I get a device context for the printer and pass it into this function properly?
...
Possible Duplicates:
How can I get the size of an array from a pointer in C?
Is there any way to determine the size of a C++ array programmatically? And if not, why?
I get a pointer to a chunk of allocated memory out of a C style function.
Now, it would be really interesting for debugging purposes to know how
big the allocate...
Hi
I want to draw a filled box in console and set colour for every single pixel.
Is it possible to achive this with ncurses?
If not - is there any other library that will do the trick?
...
Hi
I have 9 values in the form of a matrix and need to compute the median from these values as part of a simulation process. I use quicksort in C++ (i.e qsort()) which results in the process running slow (as this process iterates several times). Is there a better sorting algorithm that I could use? Thanks.
Bi.
...
Hello. Is it possible to return an object from a static method in C++ like there is in Java? I am doing this:
class MyMath {
public:
static MyObject calcSomething(void);
private:
};
And I want to do this:
int main() {
MyObject o = MyMath.calcSomething(); // error happens here
}
There are only static methods in t...
Hi,
I am new to c++ programming. I am trying to read data in a file whose contents are as follows:
AS G02 2009 01 30 00 00 0.000000 2 1.593749310156e-04 4.717165038980e-11
AS G03 2009 01 30 00 00 0.000000 2 3.458468649886e-04 4.542246790350e-11
AS G04 2009 01 30 00 00 0.000000 2 -3.176765824224e-04 2.733827659950e-...
Class A
{
public:
NullIt()
{
this = NULL;
}
Foo()
{
NullIt();
}
}
A * a = new A;
a->Foo();
assert(a); //should assert here
Is there a way to achieve this effect, memory leaks aside?
...
Hi.
I have a list of objects of the same class. The order of the list is not important.
What i want to do, is to (using bitwise operations) determine whether i should set some field with an incremental value or not. But the trick is that i want need this operation to return false (must not set field) only for the first element.
for (Ob...
hi
Imagine that I have the following variables:
unsigned long a = 1; //32-bit value
unsigned short b = 1; //16-bit value
unsigned char c ='\x01' //8-bit value
unsigned char buffer[7];
Now I would like to map or combine those variables above in the buffer as follows:
first four bytes should be occupied by value of int a, next 2 ...