c++

What is the difference from an Array compared to Dynamic Array ?

What is the difference from an Array compared to Dynamic Array ? ...

String array in C++ not working properly?

I'm working on a program for class that takes in a number from 0 to 9999, and spits out the word value (ie 13 would be spit out as "thirteen", etc) And I'm having a pain with the array for some reason. Here is the class so far: #include<iostream> #include<string> using namespace std; class Numbers { private: int number;...

GUI declarative language implementation

I've recently begun working on a project regarding GUI building using some form of declarative language. What i mean is that i need to describe an hierarchy of objects, without specifying the type of GUI widgets that will be used to "show" that hierarchy. For example, for some existing hierarchy H, using JSON notation (or something like ...

WINAPI main function

hi guys, could you please explain to me the WINAPI word in winmain header ? in the simpliest way.. #include <windows.h> int -->WINAPI<-- WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { MessageBox(NULL, "Goodbye, cruel world!", "Note", MB_OK); return 0; } is it just some windows f...

How to know when a wxFrame is closed?

Hello. I have a wxDialog where I open a wxFrame. Now I want to know when the wxFrame is closed, so I can do something in the Dialog caller [on the frame I modify a list which is present too in the dialog, and I need to update this (with a function provided by me)]. Any Ideas? I'm using C++ with wxWidgets 2.8-10 Here is the code of the ...

Blocking WM_QUIT

Quick question. I have an app that use a native DLL through PInvoke, this DLL may call a PostQuitMessage(). How can I avoid it? (as my app should not close) I tried AddMessageFilter, but it doesn't trigger the WM_QUIT. ...

Find the numbers missing

If we have an array of all the numbers up to N (N < 10), what is the best way to find all the numbers that are missing. Example: N = 5 1 5 3 2 3 Output: 1 5 4 2 3 In the ex, the number 4 was the missing one and there were 2 3s, so we replaced the first one with 4 and now the array is complete - all the numbers up to 5 are there. I...

OOP: self-drawing shapes and barking dogs

Greetings. Most of the books on OOP I've read used either a Shape class with a Shape.draw() member function or a Dog class with a Dog.talk() member function, or something similar, to demonstrate the concept of polymorphism. Now, this has been a source of confusion for me, which has nothing to do with polymorphism. While... class Dog : ...

write a C or C++ library with "template"

Hi, (1). When using C++ template, is it correct that the compiler (e.g. g++) will not compile the template definition (which can only be in header file not source file) directly, but generate the code based on template definition for each of its instantiations and then compile the generated code for its instantiations? (2). If I want ...

html2text library

There is utility html2text in linux. How can i use its or similar library in my c++ code? For example to convert html which was retrieved from any site to a readable text. ...

PyQt with c++ classes

Hi everyone, i want to use from PyQt application classes (lib/tool) written on c++ with Qt usage. I searched for solution and found Boost.python. Is it a good decision or there are a better tools for this purpose? Thank you, Kenn ...

How can I use Boost::Python to add a method to an exported class without modifying the base class?

I have a class in C++ that I can't modify. However, that class holds an std::list<> of items that I need to be able to access in a Python extension. Since Boost::Python doesn't seem to have a built-in conversion between an std::list and a Python list, I was hoping to be able to write a method in C++ that could do this conversion for me...

g++, R_X86_64_32S : what is it ?

Hello. I write a 3D engine in C++ with OpenGL. I usually work on this project on my archlinux 64 bits, but on theese holidays I do on a 32 bits system. I use subversion, and since the last svn up on my 64 bits system, I've got errors : http://pastebin.be/23730 core, wrapper and interface are compilet using the -fPIC option, I do not un...

C++ Linked list behavior

I have some C code, where in there are two linked lists(say A and B) and A is inserted at a particular position into B and A still has elements. How do I simulate the same behavior effectively using the C++ STL? If I try splice, it makes the second one empty. Thanks, Gokul. ...

How do I work with nested vectors in C++?

I'm trying to work with vectors of vectors of ints for a sudoku puzzle solver I'm writing. Question 1: If I'm going to access a my 2d vector by index, do I have to initialize it with the appropriate size first? For example: typedef vector<vector<int> > array2d_t; void readAPuzzle(array2d_t grid) { for(int i = 0; i < 9; i++) ...

Is it possible to have an instance of a class as a data member of another class?

I have a Board class where the constructor takes in the dimensions of the board as the parameter. I also have a Puzzle class that holds pieces and I want it to have a Board as a data member. I want it like this so that when I create an instance of Puzzle, I will have my instance of board created as well so I dont have to make seperate ...

Returning a copy of an Object's self in C++

Ok, So I've googled this problem and I have searched stack overflow but I can't seem to find a good answer. So, I am asking the question on here that is particular to my problem. If it is an easy answer, please be nice, I am new to the language. Here is my problem: I am trying to write a method for a C++ class that is overloading an ope...

Simple expression parser example using Boost::Spirit ?

Is anyone aware of an online resource where I can find out how to write a simple expression parser using Boost::Spirit?. I do not necessarily need to evaluate the expression, but I need to parse it and be able to return a boolean to indicate whether the expression is parsable or not (e.g. brackets not matching etc). I need the parser t...

Getting the current play position from Audacious2/Audtool?

I am currently writing a java application that uses audacious2 and audtool for playing an mp3 file in the background. I can't seem to find a way to figure out where in the currently playing file audtool is (the current play counter). I can easily call "audtool2 playback-seek 25" or something similar to go to a particular spot, but how ...

C++ null string

I have a function in a C++ program returning a string. On certain conditions, e.g. if the function encounters an error or so, I want to return a special value telling the caller that something has gone wrong. I could basically just return an empty string "", but the function does need the empty string as normal return value. How can I...