c++

structure member name - search

hi, In the previous question, i made a big mess there. So i want to give it a new try. struct emp { int salary; string empid; }; struct payroll { int empid; int deductions; }; emp a1,a2, a3; a1.salary = 9000; a1.empid = 1; a2.salary = 1000; a2.empid = 2; a3.salary = 9000; a3.empid = 3; ...

Sending C strings and vectors to MurmurHash gives inconsistent results.

I'm trying to use MurmurHash (returning 64 bit hashes on a 64bit comoputer) and have sent it the simple 3 letter string 'yes' as follows char* charptr = "yes"; cout << MurmurHash64A(charptr, 3, 10); (where 3 is the length and 10 is the seed) This gives a 64bit hashed response as expected, I can set up more pointers to C strings holdin...

Behavior of post increment in cout

Possible Duplicate: post and pre increment in c #include <iostream> using namespace std; main(){ int i = 5; cout << i++ << i--<< ++i << --i << i << endl; } The above program compiled with g++ gives output : 45555 While the following program: int x=20,y=35; x =y++ + y + x++ + y++; cout << x<< endl << y; gives res...

QT: Pause function flow till QWebView SIGNAL is completed

Hello! I'm a mostly webdeveloper, so my question can be somekind of a beginners. I'm writing a function which works with QWebView content, some kind of a macro script which makes action on loaded web page. code is something like that: somefunction() { QWebView *webView; webView->load(QUrl("http://www.google.com")); <...> here I want...

automatically compare two series -Dissimilarity test

I have two series, series1 and series2. My aim is to find how much Series2 is different from Series1,on a bin to bin basis, (each bin represents a particular feature,) automatically/quantitatively. This image can be seen in its original size by clicking here. Series1 is the expected result. Series2 is the test/incoming series. I am pr...

Sending a C++ struct over UDP in Java

Hi all, I'm a C++ programmer and have a need to set up some UDP communications between a java android app and the C++ server running on a PC. I have structure that I need to receive on the PC that consists of the following: int int float Unfortunately I'm totally at a loss as to how I can do this with Java. I need to create a Datag...

C++ Template - Multiple types

consider the following template class. template <class T> class MyClass { void MyFunc(); } template <class T> void MyClass<T>::MyFunc() { //...implementation goes here } I need to add another function MyFunc2 which accepts an additional Template arg T2 i.e template <class T> class MyClass { void MyFunc(); template <clas...

C structure pointer dereferencing speed...

Hello. I have a question regarding the speed of pointer dereferencing. I have a structure like so: typedef struct _TD_RECT TD_RECT; struct _TD_RECT { double left; double top; double right; double bottom; }; My question is, which of these would be faster and why? CASE 1: TD_RECT *pRect; ... for(i = 0; i < m; i++) { if(p[...

typedef for enum from template base class

Followup on an answer from last night - I was hoping more comments would answer this for me but no dice. Is there a way to achieve this without inheritance that does not require the cumbersome usage in the penultimate line of code below, which writes the value to cout? struct A { enum E { X, Y, Z }; }; template <class ...

Disable a column of a QTreeWidgetItem or remove set CheckBox

Hi, I have QTreeWidgetItem set in a QTreeWidget with 2 columns. Both cells got a CheckBox set by setCheckState(...). When the user unchecks the CheckBox in my first column I uncheck the second CheckBox in column 2. Now, I would like to prevent the user to check this second CheckBox again. Is it possible to remove this CheckBox in colu...

Adding QtSoap Reference to Qt Creator

i have built the dll its QtSolutions_SOAP-2.7d.dll and now i want to reference that in Qt Creator how do i do that ? thanks ...

How to optimize a cycle?

I have the following bottleneck function. typedef unsigned char byte; void CompareArrays(const byte * p1Start, const byte * p1End, const byte * p2, byte * p3) { const byte b1 = 128-30; const byte b2 = 128+30; for (const byte * p1 = p1Start; p1 != p1End; ++p1, ++p2, ++p3) { *p3 = (*p1 < *p2 ) ? b1 : b2; } } ...

Advantages of using boost::mpl::bool_ instead of a const bool

I am confused about the advantages of using the the bool_<true> and bool_<false> types against simply using const bools in the context of template metaprogramming. The boost::mpl library clearly prefers the first approach, and defines helper functions like and_, or_ to help manage such bool_. Conditional metafunctions like if_...

c++ std::vector Orphan Range error

A program dealing with graphs(from graph theory) representation and transformation.The adjacency list and matrix are implemented like dynamic arrays of vectors(don't ask why not vector of vector) for the following function program exits with memory error and compiler pointing to the orphan vector definition. int vertex,edges; vector<int...

How bad is to use void pointer in std::vector declaration?

I have to different classe: class text { }; class element { }; And I want to store them in the class node: template <typename T> class node { T cargo; std::vector<void*> children; node(T cargo) : cargo(cargo) { }; void add_child(T node) { this->children.push_back((void*) node); } } So I would...

Variable creation on heap or stack in C++

Circle is a class, with public method GetDiameter(). What is the difference between the following 2 sets of code? Qn1: Does Method 1 allocates memory for c on stack (hence no need free memory), while Method 2 allocates memory for c on heap (need manually free memory)? Qn2: When should we use Method 1 or Method 2? Method 1: void Init(...

comparison operator

hi, It may be silly question. Is there any way to give comparison operator at runtime using string variable. Suppose i have a data of salaries in vector. vector < int > salary; Input: salary[i] != /* ==,>,<,>=,<= (any comparison operator)) */ 9000. The input given like above. I store the comparison operator in string str. str = (an...

boost::regex_search - boost kills my brain cells, again

Good programmers keep simple things easy right? And it's not like the boost documentation makes your life less uneasy... All I want is an implementation for: // fulfils the function of a regex matching where the pattern may match a // substring instead of the entire string bool search( std::string, std::string, SomeResultType ) So it...

Pushing a lua table

I have created a lua table in C, but i'm not sure how to push that table onto the top of a stack so I can pass it to a lua function. Does anyone know how to do this? This is my current code: lua_createtable(state, libraries.size(), 0); int table_index = lua_gettop(state); for (int i = 0; i < libraries.size(); i++) { lua_pushstring...

Avoiding column name redundancy accessing SQL databases?

Hello, I'm working on a program using a SQL database (I use SQLite). What my program does is the following: Creates the tables in the database if they don't exist (on startup) Executes SQL queries (SELECT, UPDATE, DELETE) - decided by the user from the interface What I saw doing this is that there is a lot of redundancy. I give the ...