c++

wxWidgets: wxString::wxString(int) private within this context

I have a subclass of wxHtmlListBox called TestClass, but I get the error: /usr/include/wx-2.8/wx/string.h:682:0 /usr/include/wx-2.8/wx/string.h:682: error: 'wxString::wxString(int)' is private MainFrame.cpp:106:0 MainFrame.cpp:106: error: within this context MainFrame.cpp line 106 is this: TestClass *tc = new TestClass(this,...

Best way to do alpha blending with OpenGL?

I'm drawing 2D Polygons, actually I'm drawing lots of triangles and using GLUOrtho2D. I noticed that by zooming out I got much better frame rates. I realized I was maxing out the graphics card's fill rate, not drawing too many polygons as I had initially suspected. I think this is because I'm drawing lots of overlapping polygons and usin...

Set individual bit in C++

Hi, I have a 5 byte data element and I need some help in figuring out how in C++ to set an individual bit of one of these byte; Please see my sample code below: char m_TxBuf[4]; I would like to set bit 2 to high of byte m_TxBuf[1]. 00000 0 00 ^ This one Any support is greatly appreciated; Thanks! ...

C++: Determine if map contains a value for a key?

What is the best way to determine if a STL map contains a value for a given key? #include <map> using namespace std; struct Bar { int i; }; int main() { map<int, Bar> m; Bar b = {0}; Bar b1 = {1}; m[0] = b; m[1] = b1; //Bar b2 = m[2]; map<int, Bar>::iterator iter = m.find(2); Bar b3 = iter->secon...

Safe Unity Builds.

I work on a large C++ project which makes use of Unity builds. For those unfamiliar with the practice, Unity builds #include multiple related C++ implementation files into one large translation unit which is then compiled as one. This saves recompiling headers, reduces link times, improves executable size/performance by bring more func...

Weird Pointer issue in C++

I'm running into a VERY frustrating pointer issue. I previously posted here: http://stackoverflow.com/questions/3114997/tough-dealing-with-deeply-nested-pointers-in-c But that post got overly long and is stale, so I chose to repost with more details. Here is my header file that defines my types: #include <string> #include <vector> #i...

naming convention - underscore in C++/C# variables

It's usually to see a _var variable name in a class field. What does the underscore mean? Is there a reference for all these special naming convention? Thanks. ...

multiple definition linker error after adding a function to a previously linking file

So my program is working fine. Compiling, linking, running, the works. Then, I decide to add a simple function to one of my files, like this: #ifndef UTILITY_HPP #define UTILITY_HPP /* #includes here. There's no circular include, I've checked. */ namespace yarl { namespace utility { (several function declarations an...

I can't make this dijkstra code compille can anyone help me? (THE ALGORITHM DESIGN MANUAL)

This Code is a code i built from the algorithm design manual book but i can't make it compile cause i've got little experience with pointers i think that's the main reason i think i can't compile it : And if someone can change a little bit in the djikstra to make it through heap with the current configuration. PLEASE HELP. #include<ios...

How can a derived C++ class clone itself via a base pointer?

Hi... Here's what I'm trying to do (this code doesn't work): class Base { virtual Base *clone() { return new Base(this); } virtual void ID() { printf("BASE"); }; class Derived : publc Base { virtual Base *clone() { return new Derived(this); } virtual void ID() { printf("DERIVED"); } } . . Derived d; Base *bp = &d; Bas...

Is there a standard C++ class that is like QByteArray?

Is there a STL C++ class that works like QByteArray? ...

C++ each class depends on the second one

Let's say I have two classes: class One { Two *somevar = new Two; // (...) }; class Two { One *somevar = new One; // (...) } And it's impossible to compile something like that. How to handle it? ...

Is the C99 preprocessor Turing complete?

After discovering the Boost preprocessor's capabilities I found myself wondering: Is the C99 preprocessor Turing complete? If not, what does it lack to not qualify? ...

How many gumballs in the jar. 2 errors

Trying to code a guess how many gumballs in the gumballs jar, kinda thing. There are two problems I keep getting: It's supposed to say if the guess is to high or to low but that only happens when i enter a number over 1000 and it says: Enter your guess: 1001 Too High! Too Low! Enter your guess: If you type a letter or phrase it go...

Using boost::mpl::lambda to remove types from a boost::mpl::list based on static const member variable

I have a list of types defined as: typedef boost::mpl::list<Apple, Pear, Brick> OriginalList; I would like to create a second list that does not contain any fruit, i.e. the resultant list formed from the first list would contain a single type Brick. Fruit is identified through a static const variable defined within the types, e.g.: s...

C++ state design pattern with multiple state machines

Hi, I have a C++ state machine implemented using the State design pattern. Each state is implemented as a nested friend class of the context class. class Context { public: /* The Context class' user calls process1() to get it to perform an action */ void process1(); private: class IState; void switchState( IState *newState ); ...

C++ libcurl http response code issues

Hello everyone, This issue/quirk/side-effect is driving me crazy. Near the bottom the code, the response code of the HTTP interaction is passed by reference into responseCode_. However it often comes out as 0 even though the site can otherwise be accessed, and returns too quickly to be a timeout... All variables are defined, the code b...

Sed to remove underscores and promote character

Hi, I am trying to migrate some code from an old naming scheme to the new one the old naming scheme is: int some_var_name; New one is int someVarName_: So what I would ilke is some form of sed / regexy goodness to ease the process. So fundamentally what needs to happen is: find lower case word with contained _ replace underscore w...

Organizing test project and main executable - C & C++

I have the following directory structure. root --src ---tests src contains the source & header files (C files) for the application. When this application is built, it generates an executable. tests directory contains unit test cases (C++ files, using UnitTest++ as testing framework) for the application. In the testing project, I can ...

Why does my timer stop ticking?

I'm creating a drawing application that renders OpenGL when it gets a WM_SCROLL or WM_MOUSEMOVE. The thing is that there are a lot of mouse moves and I only need it to render a maximum of 60 frames per second. So I created a bool in my engine class called CanRender. so in my render() proc I do: if(!CanRender) { return; } CanRender = fal...