c++

QGraphicsView/QGraphicsScene rendering question

I am using QGraphicsScene/QGraphicsView pair in my application. I had subclassed them for my purpose. The code snippet that generate the pair is below: itsScene = new QGraphicsScene; itsView = new QGraphicsView; itsView->setParent(itsCanvas); itsView->setGeometry(20,20,1700,720); itsView->setBackgroundBrush(Qt::black); itsView->setAlig...

in gcc how to force symbol resolution at runtime..

Hi, My first post on this site with huge hope:: I am trying to understand static linking,dynamic linking,shared libraries,static libraries etc, with gcc. Everytime I try to delve into this topic, I have something which I don't quite understand. Some hands-on work: bash$ cat main.c #include "printhello.h" #include "printbye.h" void ...

Why do I get segfaults when declaring a struct globally or extern?

I have a struct defined in a header as follows: #define LC_ERR_LEN 300 typedef struct dLC_ERRMSG { short nr; short strategy; char tx[LC_ERR_LEN]; } LC_ERRMSG; Which I use in my code as such: LC_ERRMSG err; char *szError; szError = strerror(sStatus); snprintf(err.tx,LC_ERR_LEN," %s - %s",szFilename,szError); /* do something w...

Is there a way to get deque's internal storage size as vector::capacity?

I understand that both deque and vector reserve some space for growth. vector::capacity() is able to get the internal reserved space for a vector. Deque doesn't have such a member in the standard. Is there some way to get this information? ...

C++: how can I write a program to read integers from a file?

When I use the code recommended in the book, I get an error. I am using NetBeans 6.8 for Mac. Here is the code: #include <iostream> #include <fstream> using namespace std; int main() { ifstream inputFile; int number; inputFile.open("MacintoshHD/Users/moshekwiat/Desktop/random.txt"); inFile >> number; cout<<endl <<number...

Reverse iterator won't compile.

I'm trying to compile a reverse iterator but my attempts to do so give a horrid mess. The minimal example of the code is... #include <iostream> #include <vector> #include <algorithm> class frag { public: void print (void) const; private: std::vector<int> a; }; void frag::print (void) const { for (std::vecto...

C++ auto call function after change variable

Is there a function in c++ that when a variable got changed it automaticly call a function? ...

How to concatenate multiple CString

All functions return CString, this is a MFC code and must compile in 32 & 64 bits. Currently I'm using CString sURI = GetURL(); sURI += GetMethod(); sURI += "?"; sURI += GetParameters(); Exists any manner to do the same like: CString sURI = GetURL() + GetMethod() + "?" + GetParameters(); ...

What's the language for Socket Server

Hi, What’s the best language and IDE to develope socket server? I want a language I can learn quickly that will work on an enterprise level. Please set me up with some good resources:) Thanks RECOMMENDED LANGUAGES 'I only know Flash and scripting languages' • JAVA • C languages and VB++ • PHP I’m tring to get my Flash animations to co...

Windows Service with GUI monitor?

I have a C++ Win32 application that was written as a Windows GUI project, and now I'm trying to figure out to make it into a Service / GUI hybrid. I understand that a Windows Service cannot / should not have a user interface. But allow me to explain what I have so far and what I'm shooting for. WHAT I HAVE NOW is a windows application...

3rd party header file confliction - need solution

I have to use the windows.h file in my code but it conflicts with other legacy include files on my project that I can not modify. This is in c++. How do I get around this problem, since I can not modify any of the header files in question? I thought about using a namespace but I would think you can not wrap a include in a namespace becau...

Why symbols of a shared library are not resolved at link time?

Hi all, This is my 2nd post on this site in my effort to understand the compilation/linking process with gcc. When I try to make an executable, symbols need to be resolved at link time, but when I try to make a shared library, symbols are not resolved at link time of this library. They will perhaps be resolved when I am trying to make a...

is there a good way to combine stream manipulators?

If I wanted to output a fixed width hex number with 4 digits on a stream, I would need to do something like this: cout << "0x" << hex << setw(4) << setfill('0') << 0xABC; which seems a bit long winded. Using a macro helps: #define HEX(n) "0x" << hex << setw(n) << setfill('0') cout << HEX(4) << 0xABC; Is there a better way to comb...

A good IDE for C++/Windows Programming

Possible Duplicate: Best C++ IDE or Editor for Windows What is a very simple lightweight and free IDE for developing C++ with DirectX? I use Dev-C++ for simple C/C++ programs and like it very much. However, It does not seem to support DirectX. I have also tried Express edition of Microsofts C++ environment. I was wodering i...

cin.get() is not getting out of loop

Hi, I am using the following code: #include <stdio.h> #include <iostream> using namespace std; int main () { char c ; c = cin.get() ; do { cout.put(c) ; c = cin.get() ; } while ( !cin.eof()) ; cout << "coming out!" << endl; return 0; } Problem with the above code is, its not getting out of l...

Simple API for random access into a compressed data file

Please recommend a technology suitable for the following task. I have a rather big (500MB) data chunk, which is basically a matrix of numbers. The data entropy is low (it should be well-compressible) and the storage is expensive where it sits. What I am looking for, is to compress it with a good compression algorithm (Like, say, GZip)...

Sort C++ Strings with multiple criteria

I need to sort a C++ std::vector<std::string> fileNames. The fileNames are labeled as such YYDDDTTTT_Z_SITE YY = Year (i.e 2009 = 09, 2010 = 10) DDD = Day of the year (i.e 1 January = 001, 31 December = 365) TTTT = Time of the day (i.e midnight = 0000, noon = 1200) ZONE = Will be either E or W SITE = Four letter site n...

OPENCV : reading CvSeq after SURF Extract

Hi there, I'm trying to put CvSeq data into a database (rdbms like mysql). Right now, what I could do is to store it in a file, here's what I do : Filling a CvSeq with CvExtractSurf Saving to file with CvSave But I'd like to store it in a DB instead of a File, so I guess there's a trick to read the CvSeq structure and fill a DB tab...

Calculate Execution TIme using C++, rather than using <time.h>

I need to calculate the execution time of a C++ program. I am currently using the c-style head, <time.h> with the following code: clock_t tStart = clock(); ... printf("Execution Time: %.2fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC); Is there a c++ header I can use to calculate execution time? Please note this needs to be cross-pl...

"pure virtual method called" when implementing a boost::thread wrapper interface

Hi, I have a small wrapper which centralize what's relative to threads : class Thread { protected: boost::thread *m_thread; virtual void work() = 0; void do_work() { work(); } public: Thread() : m_thread(NULL) {} virtual ~Thread() { catch_up(); delete m_thread; } inline void c...