c++

Real life use for Qt (outside of Nokia)

Is Qt an interesting platform for business apps development, outside of Nokia phones ? Why ? Strong points ? Thanks ...

How to call a pointer to method from another method

I had this problem some time ago and I gave up but lately it returned. #include <iostream> class element2D; class node2D { public: void (element2D::*FunctionPtr)(); void otherMethod() { std::cout << "hello" << std::endl; ((this)->*(this->FunctionPtr))(); //ERROR<------------------- } }; class element2D { publ...

IPhone compilation of ported code problems: sub class of template parameter base class inaccessible

check this out: template <class T> class Test: public T { public: void TestFunc() { T::SubClass bob; } }; this fails when compiling for iPhone (expected ';' before 'bob'). works on other platforms this is a simplified example of what we are actually trying to do, which is inherit from an std::map<> and inside tha...

IPhone compilation of ported code problems: variable given same name as typedef'd type failing

check this out: this compiles fine on iPhone: typedef int ATYPE; void AFunc() { ATYPE ATYPE; ATYPE = 1337; } this compiles fine on iPhone: typedef int ATYPE; typedef ATYPE _ATYPE; struct AStruct { _ATYPE ATYPE; }; void AFunc() { AStruct bob; bob.ATYPE = 1337; } but this does NOT: typedef int ATYPE; struct ...

C++: Simplifying my program to convert numbers to from one base to another.

Hello, I'm taking a beginner C++ course. I received an assignment telling me to write a program that converts an arbitrary number from any base between binary and hex to another base between binary and hex. I was asked to use separate functions to convert to and from base 10. It was to help us get used to using arrays. (We already cover...

c++ add to STL Set

I have a media program where from main() i am adding info about book, cd, dvd. every entry for cd,dvd,book has a keyword. Where i am having a problem is adding a keyword to each item. currently i have everything added but keyword. required out put -Book- author: Mark Haddon pages: 240 title: The Curious Incid...

[C++] Adding to a Memory Address Error

This doesn't compile in VSC++ 2008. void* toSendMemory2 = toSendMemory + 4; I am at a loss at why, though I am sure it's very stupid of me. :P ...

How to write an object to file in C++

I have an object with several text strings as members. I want to write this object to the file all at once, instead of writing each string to file. How can I do that? ...

Floating point calculation change depending on the compiler

When I run the exact same code performing the exact same floating point calculation (using doubles) compiled on Windows and Solaris, I get slightly different results. I am aware that the results are not exact due to rounding errors. However I would have expected the rounding errors to be platform-independent, thereby giving be the same ...

Best way to store application data when data stored and data format could change in future versions?

I'm making an Android Java app game (although this question applies to all languages really) and hope to release the first version soon. I'm nervous about how I save data in my game. My problem is that, if in a later update, I decide to store more data or store the same data in a different way, I need to be careful I don't lose or corrup...

C++: How do I pass a container of derived classes to a function expecting a container of their base classes?

HI! Anyone know how I can make the line "chug(derlist);" in the code below work? #include <iostream> #include <list> using namespace std; class Base { public: virtual void chug() { cout << "Base chug\n"; } }; class Derived : public Base { public: virtual void chug() { cout << "Derived chug\n"; } void foo() { cout << "Der...

Delete memory error

Hi, I have the following scenario. class foo { ... private: char *_test; }; void foo::setTest() { if( 0 != _test ) delete [] _test; } The function setTest throws an error when first run as it trying to delete _test when it has not been assigned yet. This is happening because _test is not set to 0X0. Can anyone help me to ...

C++ stream operator question

Hi all, I suppose this might be simple question for all the gurus here but I somehow couldn't figure out the answer. I want to be able to write csv cells to stream as simple as this: stream << 1 << 2 << "Tom" << std::endl; which would create output like 1,2,Tom. How can I achieve that? I figured that I need to create custom streambu...

The written versions of the logical operators.

This is the only place I've ever seen and, or and not listed as actual operators in C++. When I wrote up a test program in NetBeans, I got the red underlining as if there was a syntax error and figured the website was wrong, but it is NetBeans which is wrong because it compiled and ran as expected. I can see ! being favored over not but...

Visual Studio 2005 and Tinyxml - xml file location

For some reason my Tinyxml file which is created via visual studio 2005 (c++) is saved on my desktop instead of the debug folder or in the program's root folder. if anyone knows about some way to tell vs2005 to save the tinyxml create file somewhere else? I tried that with eclipse and it saved the file in the program's root folder, whi...

Sending out Ping Requests

Using WinpCap and trying to generate my own ping requests. On both machines I see the ping request and the only differences between the ones I've generated the ones Windows has generated is my checksum is 0 (been told that's ok) and the identified is 100 instead of an ever increasing value like Windows uses. (I increase each time I try ...

toString in c++? cant print a set<string>

I have a program where i am trying to print a key word string from a set Sorry i got it figured out.. ...

libcurl HTTP request to save respond into variable - c++

I'm trying to save the returned data from HTTP request into a variable. The code below will automatically print the respond of the request, but I need it to save the respond to a char or string. int main(void) { char * result; CURL *curl; CURLcode res; curl = curl_easy_init(); if(curl) { ...

Qt: Background thread refreshing UI thread

Hi, I have a background thread and the thread calls some methods that update the UI (in order to show progress bars and show additional info in text areas). If I modify some UI widget values, a "Cannot send events to objects owned by a different thread" assertion error is raised. Looking at forums, I read that I could use QMetaObject:...

How to do compare and increment atomically in C/C++

In my attempt to develope a thread-safe c++ weak pointer template class, I need to check a flag that indicating the object is still alive, if yes then increment the object's reference count and I need to do the both steps atomically. I know the existance of intrinsics functions provided by the compiler for instance _InterlockedCompareExc...