c++

[Qt/C++] How can I show a QLiskPickSelector's instance without using a button to show it ?

Hi all .. This question is related to the QLiskPickSelector class in Qt .. I want to show an instance of it but the problem is that the onle way to show it is to link it with a QMaemo5ValueButton and then have the user press that button .. Is there any other way to show this instance of QLiskPickSelector without using a QMaemo5ValueButto...

Performing an edge contraction on a graph.

I am trying to do edge contraction on a graph. n is the number of vertices in the graph. The vector f containing pairs of vertices representing an edge contains the edges which are to be contracted. The graph does not contain any self loops. Please point out any logical mistakes if any in the code. If the method is entirely wrong then...

How to set all struct members to same value?

I have a struct: struct something { int a, b, c, d; }; Is there some easy way to set all those a,b,c,d into some value without needing to type them separately: something var = {-1,-1,-1,-1}; Theres still too much repetition (lets imagine the struct has 30 members...) I've heard of "constructs" or something, but i want to set t...

How to apply multiple textures to a VBO of a cube?

Dear reader, I'm new to VBO's and read some articles on creating and using VBO's. I am working on a application where I want to create a dozen of rotating cubes. I'm connected to a server which pushes text messages to my application. When I receive 6 text messages, I render these messages using Pango and Cairo. Then I want to create t...

c++ Function pointer declaration causes program to crash on exit.

I declare the following two function pointers in my class: void (*ptrFunc)(void *); bool (*ptrValid)(char *); Now for some reason, the second pointer (ptrValid) causes the program to crash on exit. When I comment out the declaration the program exits fine, but when I un-comment it, it crashes. Nothing is being assigned to it, it isn...

Requirements for directly returning a class instance from a function?

I'm got a function in C++ that wraps an output stream constructor so it can pass in a pointer to a parent class that it's running in, ala: pf_istream PF_Plugin::pf_open_in() { return pf_istream(this); } When I do it that way, however, I get something like this: pf_plugin.cc:103: error: no matching function for call to ...

int var = 1; void main() { int i = i; }

This is an interview question that I had: int var = 1; void main() { int i = i; } What is the value of i after assignment? It is really compiler dependent or is it just undefined? My g++ on cygwin seems to give me 0 all the time. Thanks ...

creating a 2D array of vectors

I have been trying to create a 2D array of vector for a game. Here is an example of what I am doing. struct TILE { int a; char b; bool c; }; TILE temp_tile; std::vector<TILE> temp_vec_tile; std::vector<std::vector<TILE>> tile; for (int x = 0; x < 10; x++) { for (int y = 0; y < 10; y++) { temp_tile.a = x; tem...

nested class access control in C++

Can inner class access a private member variable of its enclosing class? There seems to be some contradictions on the internet and compiler. Compile (g++ on cygwin) allows it. But, some technical documents say that it is not allowed. ...

Implications of a const_cast in a copy constructor?

So I've got an output stream class that owns a pointer to a class that actually does the writing, and I need a copy constructor so that I can return initialized instances from a function so that I can bind certain values transparently to the user. To have reasonable copy semantics I'd really like to clear the writer pointer in the copie...

Why does boost::asio appear to do nothing.

I'm trying to implement the irc protocol in a very basic manner. My first attempt is to use boost::asio and connect to a server and read the motd. AFAIK the motd is sent to every client when they connect. I have made the following test program and it seems to not do anything. It's not a very good piece of code but this is all I have afte...

c++ container search by key and value

I'm trying to build a container of string representations of ordinal numbers, searchable both by the string and by the number. For example, I can do it trivially, but inefficiently, with an array: std::string ordinalStrings = {"zeroth", "first", "second",..} getting the string with ordinalStrings[number], and the integer with a while(...

Help identifying memory leak

I have a class here that is defined like this: struct USERFPOINT { POINTFLOAT UserPoint; POINTFLOAT LeftHandle; POINTFLOAT RightHandle; bool isBezier; }; struct SHAPEOUTLINE { GLuint OutlineVBO; int OutlineSize; int OutlineWidth; ARGBCOLORF OutlineColor; }; struct SHAPECONTOUR{ std::vector<USERFPOI...

File handle leak on dynamically loaded DLL caused by activation context

I have a dynamically loaded & unloaded DLL which requires COMCTL32.dll >= v6.0 and MSVCR >= v9.0. To ensure that the correct versions are loaded, I enable manifest file generation in Visual Studio project setting, and add this entry to another manifest file: <dependency> <dependentAssembly> <assemblyIdentity type...

C++ return value versus exception performance

hi. Somewhere I have read that modern Intel processors have low-level hardware for implementing exceptions and most compilers take advantage of it, to the effect that exceptions become faster than returning results state using variables. Is it true? are exceptions faster than variables as far as returning state/responding to state? re...

how do i create and save a data file in a folder of my choice

how do i create and save a data file in a folder of my choice in C++ program? ...

What is the difference between a .h(header file) and a .cpp file?

I am creating a windows:forms application. I have read some of the answers give to try to understand the concept of .h(header file) & .cpp(implementation files). As I created the GUI for my app. I noticed the code being placed in the .h file. But when I double clicked a button control to add code to the procedure, the code was created in...

http c++ library?

Hi i am wondreing if there is some kind of c++ library that deals with http, http chunking etc. Google did not find anything :D ...

Inplace Win32 listview editing is always canceled

I have a listview in small icon mode on a modeless Win32 dialog with LVS_EDITLABELS set. Regardless of whether editing was begun by a mouse click or programmatically by calling ListView_LabelEdit() and regardless of whether ESC or RETURN was hit upon finishing editing, when LVN_ENDLABELEDIT notification is received pszText of NMLVDISPINF...

How to write own dynamic_cast

Hi, This have been asked in the interview. How to write own dynamic_cast. I think, on the basis of typeid's name function. Now how to implement own typid? I have no clue on it. ...