c++

QDBusAbstractAdaptor vs. QDBusAbstractInterface

When exposing some code to D-Bus using Qt D-Bus bindings, when should one use a Qt Adaptor over a Qt Interface? I'm having a difficult time understanding how exactly they differ since it seems like they provide the same functionality. ...

size_t vs container::size_type

I'm wondering if there's a difference in using size_t and container::size_type? What I understand is size_t is more generic and can be used for any size_types.. Is container::size_type more optimized for a specific container though? ...

How can I redefine a built in keyboard shortcut's behavior?

I am attempting to re-implement the Copy behavior for a QTextEdit object. The custom context menu I create works as expected when the 'Copy' button is clicked, but Ctrl+C isn't being handled correctly. Since the context menu doesn't have any issues, I'll omit that portion of the code. // Create a text edit box for text editing QTextEdit...

generate sha hash in openssl

how do i generate sha-1, sha-2 using openssl libarary, searched google and could not find function or any example code ...

Linkedlist Node in C+

I am learning a book on data structures, and complied their node in linked list example, and I receive this error: and Everything.cpp|7|error: expected unqualified-id before "int"| and Everything.cpp|7|error: expected `)' before "int"| ||=== Build finished: 2 errors, 0 warnings ===| The code for the node is: typedef struct Node { ...

Random number generator that produces a power-law distribution?

I'm writing some tests for a C++ command line Linux app. I'd like to generate a bunch of integers with a power-law/long-tail distribution. Meaning, I get a some numbers very frequently but most of them relatively infrequently. Ideally there would just be some magic equations I could use with rand() or one of the stdlib random functi...

Error installing Windows SDK v6.1 with windowssdkver command: Input string was not in a correct format

When installing Windows SDK v6.1, following the chromium instructions (http://dev.chromium.org/developers/how-tos/build-instructions-windows) I run the following command: windowssdkver -version:v6.1 -legacy I get the following error: Input string was not in a correct format. at System.Number.StringToNumber(String str, NumberStyle...

5D array hash table

I currently have a 5D array in the variable called template written into 1D array called template1D, with a hash table of 3456 (8 * 12 * 3 * 4 * 3) entries. In Matlab, the multi-dimensional array was accessed as follows: template{idx_r, idx_l, idx_rho, idx_alpha, idx_beta} However, as I have the indices going from 0-7, 0-11, 0-2, 0-3,...

What is the difference between accesing vector elements using an iterator vs an index?

What advantages are there in accessing vector elements using an iterator vs an index? ...

C++ Deleting a node in Queue

Problem1: Deleting in a node in a list > 3 Description: Deletion of the sixth node in a list of seven, results in a print of only the first and last node. Available Node Pointers: next, prev, data Function to delete the specified node is in the LinkedList.cpp Name: DeleteNode. Function that traverses through the list to print the no...

regarding writing with TCP/IP in symbian

void CSocket::WriteSocket() { TBuf8<2> KData (_L8("60")); //RBuf8 KData; RBuf8 aQuery; aQuery.CleanupClosePushL(); aQuery.CreateL(100); // <?xml version="1.0"?><AM><P/><A><CE/></A></AM> _LIT8(KData1,"61"); //_LIT8(KData2,"20"); _LIT8(KData3,"A"); _LIT8(KData4,"<?xml version=\"1.0\"?><AM><P/><A><CE/></A></AM>"); TBuf8<100> buff,...

Moving heavily templatized C++ code to Java

I have an application written in C++ (makes heavy use of templates) that I need to take to the Java ME platform. I have two questions: Are there any good tools to convert C++ code to Java - do some basic stuff so I have a platform to start with. I found this - http://tangiblesoftwaresolutions.com/Product_Details/CPlusPlus_to_Java_Conv...

C++: Why is the copy ctor used in this code?

class A { public: A(const int n_); A(const A& that_); A& operator=(const A& that_); }; A::A(const int n_) { cout << "A::A(int), n_=" << n_ << endl; } A::A(const A& that_) // This is line 21 { cout << "A::A(const A&)" << endl; } A& A::operator=(const A& that_) { cout << "A::operator=(const A&)" << endl; } int foo(const A& a_...

std::multimap compile errors

I am trying to use multimap for the first time but my app will not compile. TIA Paul.. // file dept.h typedef std::multimap <CString, std::map< CString, CString> > _DeparmentRecord; // also tryied replacing CString with LPCWSTR _DeparmentRecord DeparmentRecord; // file dept.cpp DWORD CIni::AddNameValue(LPCWSTR Section, LPCWSTR Nam...

Capturing video from a webcam in VC++

Other than DirectShow, what are the other options? I want to use this in an instant messaging application currently under development. Thanks ...

How to fix "/lib/tls/libc.so.6: version `GLIBC_2.4' not found"?

I compiled a binary and copied on another machine for execution. But I am getting the above error. On the second machine, I cannot install new libraries. I tried putting the libc from the first machine into the directory of the binary on the second machine, but the linker (as I found using ldd) still loads from the standard path /lib/tls...

What is the purpose of __cxa_pure_virtual?

Whilst compiling with avr-gcc I have encountered linker errors such as the following: undefined reference to `__cxa_pure_virtual' I've found this document which states: The __cxa_pure_virtual function is an error handler that is invoked when a pure virtual function is called. If you are writing a C++ application that has pure...

How to visualize bytes with C/C++

I'm working my way through some C++ training. So far so good, but I need some help reinforcing some of the concepts I am learning. My question is how do I go about visualizing the byte patterns for objects I create. For example, how would I print out the byte pattern for structs, longs, ints etc? I understand it in my head and can under...

Why do some const variables referring to some exported const variables get the value 0?

Consider the following. I have two exported constants as follows: // somefile.h extern const double cMyConstDouble; extern const double cMyConstDouble2; and // somefile.cpp const double cMyConstDouble = 3.14; const double cMyConstDouble2 = 2.5*cMyConstDouble; These constants are now referenced some place else to define two static (...

C++, removing #include<vector> or #include<string> in class header

I want to remove, if possible, the includes of both <vector> and <string> from my class header file. Both string and vector are return types of functions declared in the header file. I was hoping I could do something like: namespace std { template <class T> class vector; } And, declare the vector in the header and include it ...