c++

got stuck on using prepare() and bindvalue() in c++ QT

hi , I've written a SQL query based on QT assisstant and it says that you can use the prepare() method instead of exec() then you can pass your parameter by the help of two methods called : bindvalue() and addbindvalue() here is an snippet code of my problem : Query->prepare("SELECT ID , Row , Col FROM sometable WHERE Row = :row AND Co...

Is there a language with RAII + Ref counting that does not have unsafe pointer arithmetric?

RAII = Resource Acuquisation is Initialitazation Ref Counting = "poor man's GC" Together, they are quite powerful (like a ref-counted 3D object holding a VBO, which it throws frees when it's destructor is called). Now, question is -- does RAII exist in any langauge besides C++? In particular, a language that does not allow pointer arit...

How do I mmap a _particular_ region in memory?

I have a program. I want it to be able to mmap a particular region of memory over different runs. I have the source code of the program. C/C++ I control how the program is compiled. gcc I control how the program is linked. gcc I control how the program is run (Linux). I just want to have this particular region of memory, say 0xabcdab...

Test framework for component testing

I am looking for a test framework that suit my requirements. Following are the steps that I need to perform during automated testing: SetUp (There are some input files, that needs to be read or copied into some specific folders.) Execute (Run the stand alone) Tear Down (Clean up to bring the system in its old state) Apart from this I...

Newbie QT question about connect

Hi, I just tried to set up a small QT example and the connect statement fails to compile. the error message from the compiler is: "no matching function for call to 'MainWindow::connect(...'" what am I doing wrong her? Thank you for your help. #ifndef MAINWINDOW_H #define MAINWINDOW_H #include <QMainWindow> #include <QNetworkAccessMa...

What's the best way to program c++ on a Mac?

What is the best software ( open source ) for programming on c++ a Mac ? any suggestions? ...

mysqlclient library linkage problem

I am linking an application with mysqlclient library on 64-bit CentOS 5.4 and get a linkage error (cannot find -lmysqlclient). The library is in /usr/lib64/mysql/: una@localhost$ ll /usr/lib64/mysql/ total 9072 ... lrwxrwxrwx 1 root root 26 Jan 3 15:54 libmysqlclient_r.so -> libmysqlclient_r.so.15.0.0 lrwxrwxrwx 1 root root ...

Difference of Enum between java and C++?

Hi I am learning Enums in java I like to know what are the majao differences of Enum in java and C++. Thanks ...

QScintilla, example project doesn't work

I wanted to try QScintilla out. So i downloaded and installed it, no problems. When i ran the example project it said I was missing QtCored4.dll, so i copied it into the directory, then it said it needed other dll's aswell so copied them too. At the end it gives me a Visual C++ Runtime error. It just says it terminated in an unusual way...

How to create a virtual file ?

I'd like to simulate a file without writing it on disk. I have a file at the end of my executable and I would like to give its path to a dll. Of course since it doesn't have a real path, I have to fake it. I first tried using named pipes under Windows to do it. That would allow for a path like \\.\pipe\mymemoryfile but I can't make it w...

What to do with private member functions when turning static class to namespace in C++?

I have a class that has 5 static public functions and 1 static private function (called from one of the public functions). The class doesn't have any member variables. It seems to me that it should be a namespace and not a class. But what to do with the private function? I prefer it not to be accessible by every namespace user, but there...

Representing planar graphs / GIS topology: ArcObjects vs. CGAL arrangements

I need to represent a planar graph structure, i.e., a division of part of the plane into polygons so that I can easily find a polygon's neighbors etc (like on a map). What is the best library to use? ArcObjects? CGAL (2D arrangements)? Anything else? I use C++ under Windows. ...

Template parameters dilemma

I have a dilemma. Suppose I have a template class: template <typename ValueT> class Array { public: typedef ValueT ValueType; ValueType& GetValue() { ... } }; Now I want to define a function that receives a reference to the class and calls the function GetValue(). I usually consider the following two ways: Met...

Best way to slow down a thread? Is using Sleep() OK?

I've written a C++ library that does some seriously heavy CPU work (all of it math and calculations) and if left to its own devices, will easily consume 100% of all available CPU resources (it's also multithreaded to the number of available logical cores on the machine). As such, I have a callback inside the main calculation loop that s...

C#: Can i write "private:" or "protected:" regions like in C++

In C++ you can write: private: int w; string x; protected: int y; string z; is there something similar in C# ? ...

What is the best way to do 2D animation?

I'm writing a 2D animation class, and I've got TGA pictures in which the player animation is stored. These pictures are 8x8 tiles (so on each row there are 8 frames of a moving character) However, I don't have a clue on how to animate this in code. I was thinking about updating it by moving the u-v coordinates each frame and returning ...

Why does this static array cause an extremely long "generating code" step in release build?

I recently added a static lookup array to one of my classes, like: // MyClass.h class MyClass { static MyClass const s_fromIndex[1500]; public: MyClass(size_t arg1, size_t arg2); static MyClass fromIndex(size_t index) { return s_fromIndex[index]; } } // MyClass.cpp MyClass const MyClass::s_fromIndex[1500] = { MyClass...

Can I use the C++ Boost shared_ptr to program as if I was coding in Java, as in, not care about memory management?

It's been a while I coded in C/C++, and now I need its efficiency for a project I'm doing. What I understand from this shared_ptr is that it basically deletes the object when I need it to. So, if, for example, my object has a vector of shared_ptr, I wouldn't have to worry about iterating through the vector and deleting each element in t...

Very strange malloc error.

Ok. So I have this function, init(): void init() { fstream file; int index = 0; char temp_list[60000][15]; listlen = 0; current_index = 0; file.open("en_US.dic"); while(!file.eof()) { file >> temp_list[index]; index++; } listlen = index; file.close(); file.open("en_US.dic"); word_list = new char*[listlen]; int count = 0...

Undefined reference to non-member function - C++

I have the following in header file. namespace silc{ class pattern_token_map { /* Contents */ }; pattern_token_map* load_from_file(const char*); } In the CPP file (this has got proper includes) pattern_token_map* load_from_file(const char* filename) { // Implementation goes here } In another CPP file. This has...