c++

The C++ Programming Language, 3rd edition solutions?

Are there any online solutions to exercises in that book? For the C bible, there's http://clc-wiki.net/wiki/K&R2_solutions, so i tought there may be the same thing for c++ bible but i couldnt really find it. ...

All possible paths in a cyclic undirected graph

I'm trying to develop an algorithm that identifies all possible paths between two nodes in a graph, as in this example. in fact, i just need to know which nodes appear in all existing paths. in the web only got references about DFS, A* or dijkstra, but i think they doesn't work in this case. Does anyone know how to solve it? ...

Documentation for Qt documentation comments? Qt + Doxygen?

Where can I find documentation for Qt documentation comments? I'm referring to how Qt uses a specific style for documentation comments, like so: /*! \class MyClassName \brief The MyClassName class is used as an example on Stack Overflow. This class serves a few functions, the most important being: \list \i So p...

what the snippet of code does

Dear all, I would like to know what the snippet of code does.. Drive[0] = 'A'; Drive[1] = ':'; Drive[2] = '\\'; Drive[3] = 0; DriveMask = GetLogicalDrives(); for( anIndex = 0; anIndex < 26; anIndex++ ) { if( DriveMask & 1 ) { Drive[0] = 'A' + anIndex; DriveMask >>= 1; } } Please let me know ...

How to give 'Everybody' full rights to a file (programmatically)

I'm modifying an old C++ program to run on Vista. It does not require Admin privileges. I've changed the code to put logfiles in \ProgramData\MyApp\. These logfiles are written with the stdio functions (fopen, fprintf, fclose). Here's the problem: UserA runs the program first, it creates \ProgramData\MyApp\MyLogFile.txt using Create...

how to get the type of a deferred template parameter

Is there a way to get the defered type of a class template parameter ? template <class TPtr> struct foo { typedef TPtr ptr_type; typedef ??? element_type; /* shall be the type of a deferred TPtr*/ }; so foo<const char*>::element_type results in const char, and foo<std::vector<int>::iterator_type>::element_type results in int. ...

synchronize Mouse wheel scroll for two independent windows

Hi.. I want two independent windows to be scroll synchronously using WIN32 C++. Right now whichever window in focused, scroll is working for only that window. But my requirement is like, with a single scroll both the windows should scroll..some one suggested me to send same scroll message for other window also...but MSDN says WM_HSCROLL...

STL in C++ how does it work

I have very technical question, I was working with C, and now I'm studying C++, if I have for example this class class Team { private: list<Player> listOfPlayers; public: void addPlayer(string firstName, string lastName, int id) { Player newPlayer(string firstName, string lastName, int id); listOfPlayers.push_...

C++: how to truncate the double in efficient way?

Hello, I would like to truncate the float to 4 digits. Are there some efficient way to do that? My current solution is: double roundDBL(double d,unsigned int p=4) { unsigned int fac=pow(10,p); double facinv=1.0/static_cast<double>(fac); double x=static_cast<unsigned int>(d*fac)*facinv; return x; } but using pow and delete seems t...

Qt - QTimeEdit as a timer viewer

I have a QTimeEdit which I want to set to some value and the each second I want to decrease by 1 the value that shows the QTimeEdit. So when it will be 0, the I want to have a QMeesageBox that says "Your time is off.". Can I some how do this with QTimeEdit interface, or I should use QTimer? ...

Daylight saving time of current tz

Hi, in my c++ software I've used Boost in some parts and also for the local time. OK, now my problem is to make a check if in my machine is active or not the DST. With the follow part of code I can know only the difference from the UTC time. In my case the difference is 2 hours because is active the DST ptime tLoc = second_clock::loca...

Are unspecified and undefined behavior required to be consistent between compiles of the same program with the same compiler in the same environment?

Let's pretend my program contains a specific construct the C++ Standard states to be unspecified behavior. This basically means the implementation has to do something reasonable but is allowed not to document it. But is the implementation required to produce the same behavior every time it compiles a specific construct with unspecified b...

Question on struct

i see lot of struct code like below struct codDrives { WCHAR letter; WCHAR volume[100]; } Drives[26]; we can use variables or array something like that to store the data.. but i am not sure why use struct in the programs. i am beginner so please for my dump question Thank you for the time spent to me ...

localtime_r supposed to be thread safe, but causing errors in Valgrind DRD

I searched google as much as I could but I couldn't find any good answers to this. localtime_r is supposed to be a thread-safe function for getting the system time. However, when checking my application with Valgrind --tool=drd, it consistantly tells me that there is a data race condition on this function. Are the common search results ...

Is it worth setting pointers to NULL in a destructor?

Imagine I have a class that allocates memory (forget about smart pointers for now): class Foo { public: Foo() : bar(new Bar) { } ~Foo() { delete bar; } void doSomething() { bar->doSomething(); } private: Bar* bar; }; As well as deleting the objects in the destructor is it also worth setting them to NULL?...

organizing external libraries and include files

Over the years my projects use more and more external libraries, and the way I did it starts feeling more and more awkward (although, that has to be said, it does work flawlessly). I use VS on Windows, CMake on others, and CodeComposer for targetting DSPs on Windows. Except for the DSPs, both 32bit and 64bit platforms are used. Here's a...

what's the best way to learn C++ and Qt at the same time?

Hi I did A Google search and couldn't find anything, so I wanna learn Qt/C++ my University (I'm a first year CompSci Student) won't be teaching C++ next year which is a big disappointment I already know Python and dabbled in LaTeX, Javascript, C++ I'm currently helping out a free software project Clementine but it's programmed in Qt/C...

Qt: QTextEdit::setTextFormat(Qt::LogText) does not exist anymore, what else can I use to log?

Hi, I need a text logger in my C++ application, QTextEdit used to have this feature until Qt 3.3 but unfortunately it has been removed. Is there an alternative that I could use? Tanks for your help! ...

What determines when a destructor is called for a temporary object in C++?

Guys I've asked few days ago a question and didn't have really time to check it and think about it, but now I've tried one of the solutions and I can't understand why does it work? I mean why destructor is called at the end of line like this: #include "stdafx.h" #include "coutn.h" #define coutn coutn() int _tmain(int argc, _TCHAR* arg...

how to load page in the background in Qwebkit?

im using Qwebkit to load heavy html page but mean while i don't what to show the user blank page , how can i in QT load the html page in the background and in the mean while show another HTML page in the same QwebKit widget ? ...