c++

How do plugin systems work?

I'm working on a project where I would find a basic plugin system useful. Essentially, I create the base class and can provide this base class to a plugin developer. Then the developer overrides it and overrides the methods. Then this is where it becomes a bit unclear to me. How does it work from here? Where could I find documentation pe...

Bit Array in C++

When working with Project Euler problems I often need large (> 10**7) bit array's. My normal approach is one of: bool* sieve = new bool[N]; bool sieve[N]; When N = 1,000,000 my program uses 1 MegaByte (8 * 1,000,000 bits). Is there a more efficient way to use store bit arrays than bool in c++? ...

"missing type specifier" error on constructor declaration

I have 2 classes in 2 different files: RegMatrix.h: #ifndef _RM_H #define _RM_H #include "SparseMatrix.h" ... class RegMatrix{ ... RegMatrix(const SparseMatrix &s){...} //ctor ... }; #endif SparseMatrix.h: #ifndef _SM_H #define _SM_H #include "RegMatrix.h" ... class SparseMatrix{ ... SparseMatrix(const RegMat...

How important is consistent usage of using declarations?

Most of the research I've done on the use of using declarations, including reading relevant sections of various style guides, indicates that whether or not to use using declarations in C++ source files, as long as they appear after all #includes, is a decision left to the coder. Even the style guides I read, which usually come down on on...

Why firefox is written in C++ and javascript UI ?

Well..I am learning java now and I am curious to know will this yield a noticeable performance increase ? And If many developers are following similar methodology for windows programming ( C++ back end and Java UI ) or other languages are used like python? *this : C++ back end and other languages for UI instead of using the other langu...

std::cin in an Array

I am a CS student trying to grasp some C++ basic concepts. I am trying to get the input of a user from std::cin and put it to an array. example : Input > ab ba cd[Entey key pressed] then I would like the array to contain [ab][ba][cd]. So far I have : #include <iostream> #include <string> int main(int argc, char** argv) { std::c...

Bi quinary coded examples

i have following problem To decode the Biquinary code use the number 5043210. At each digit multiply the biquinary number by the number 5043210. This will give you one decimal digit. For example take the number 0110000. To change this into decimal: (5 × 0) + (0 × 1) + (4 × 1) + (3 × 0) + (2 × 0) + (1 × 0) + (0 × 0) = 4 i have tried this ...

would ever passing a variable of an integral type to functions by reference be more efficient than by value?

I know that it's said when passing a variable of any integral type like int, double, long double, etc to a function; it should be done by value but I'm curious that from an assembly point(performance-wise or space-wise), wouldn't be there a situation when passing a variable of an integral type with a size bigger than pointers like long d...

C/C++ - overriding default functions

Hello! I have the following question: Does Microsoft Visual Studio (I'm using 2008 SP1) offer any way to override standart C functions such as malloc, memcpy? Suppose I have some externally built library, which contains malloc.obj and memcpy.obj. Library is called library.lib. How should I build my project so that the compiler uses m...

For what sort of 'systems programming' projects is C++ clearly superior to C?

C++ is billed as a 'systems programming language'. Yet many 'systems' projects use plain C; when they use C++, sometimes it is only for very simple classes which could easily be replaced by C structs. What kind of 'systems' projects does C++ really shine in? ...

Properties of Properties as Templates

I try to implement C++ properties as templates as defined in WikiPedia template <typename T> class property { T value; public: T & operator = (const T &i) { ::std::cout << i << ::std::endl; return value = i; } // This template class member function template serves the purpose t...

while(true) versus for(;;)

Possible Duplicates: Is for(;;) faster than while (TRUE)? If not, why do people use it? for ( ; ; ) or while ( true ) - Which is the Correct C# Infinite Loop? Is there any appreciable difference between while(true) (or while(1)) and for(;;)? Would there be any reason to choose one over the other? ...

C++ converting an int to an array of chars?

Possible Duplicate: C++ convert int and string to char* Hello, i am making a game and I have a score board in it. The score is stored in an int variable but the library im using for the game needs an array of chars for its text outputting for my scoreboard. So how do i turn an int into an array of chars? int score = 1234; ...

callstack and ReadProcessMemory

Hi! I'm trying to read the return address of the method but of another memory. so I'm getting the frame pointer, and read the value of the return value. As far as I understand I'm supposed to get a value equals to m_stackframe.AddrReturn.Offset, but: If I add the Esp to the frame pointer address - ReadProcessMemory returns false. If I ...

Cold startup optimization

I tried to search, but so far with no luck. Does anyone know a good resource how one should do cold start optimizations? The app in question is C++/MFC app, compiled with VS2010, full version, with built in profiler available. I have tried to cut down all the extra weight to get the load times acceptable for warm start, but the cold sta...

calling an objects function while inside a different objects function

For some reason i can't seem to get this right ok i have 2 objects class score { public: int scored(int amount); private: int currentscore; } int score::scored(int amount) { currentscore += amount; return 0; } class collisions { public: int lasers(); } // ok heres my issue int collisions::lasers() { // some code h...

When is an empty namespace definition needed?

Namespaces aren't declared and defined like most other things, but the namespace equivalent of a forward declaration would be: namespace X {} // empty body Normally, you define a namespace by placing other declarations inside it. But is there a problem for which this "namespace forward declaration" is the easiest solution? Of what ...

Access Objective-C variable from C++ function

I'm working on a project that just needs to be rewritten but that is not an option at this point. I have a C++ function that is called and does all kinds of stuff. I need it to read a variable from the App Delegate class. For example I have: @interface MyAppDelegate : NSObject <UIApplicationDelegate> { UIWindow *window; MyVi...

applying texture have HUGE problem. directx 9 c++

i don't get any errors when i compiile my game the only problem is that it won't apply the texture it will apply a color, i know it is werid. like if texture has two colors white and red than white will be applied. here is my code // Monopoly.cpp : Defines the entry point for the application. // #include "stdafx.h" #include "Monopoly.h...

MFC data forwarding to main thread via PostMessage

I have a C++/MFC application I need to restructure. The app used to process most of the data on the main thread, therefore blocking the input, and now I want to change it so, that all GUI updates are done through PostMessage. Unfortunately, I can't seem to find a good source on how to achieve this goal. Right now I'm thinking of creati...