c++

TFTP source code examples

Could someone point me to the source code for an ideally multi-threaded C++ TFTP application. Even better if it's written using boost asio. Just wanting to get an idea of how to structure a multi-threaded c++ network app with UDP rather than TCP. I'll choose the answer based on how readable the code is and being in C++. ...

returning std::string/std::list from dll...

Short question. I just got a dll I'm supposed to interface with. Dll uses crt from msvcr90D.dll (notice D), and returns std::strings, std::lists, and boost::shared_ptr. Operator new/delete is not overloaded anywhere. I assume crt mixup (msvcr90.dll in release build, or if one of components is rebuilt with newer crt, etc) is bound to ca...

Multidimensional array of object in C++ , I can not initialize it!

Hi everyone! Rookie C++ Programmer here again I'm using VC++ VS2008 and making an attempt at creating an array of arrays. All objects I wish to store I want to put on the heap. In the arrays it's all just pointers. Here's some code: Grid.h #include "Tile.h" class Grid { public: Tile* grid_ptr[8][8]; ... ... }; Grid.c...

Ternary operator ?: vs if...else

In C++, is the ?: operator faster than if()...else statements? Are there any differences between them in compiled code? ...

C++ Void non-pointer

I was wondering, why can't there be a void data type that is not a pointer? Surely you could get past the whole determined size thing by having void4 void8 void32 And then only being allowed to 'cast' a void data type to another class if its size is equal or under to the classes size. Is there something that I'm missing, or does the...

How do I reference a 32 bit DLL in a 64 bit project?

I've got a C# 2.0 project which is set to target 'Any Cpu', however it is referencing a C++ project that's building a 32 bit dll. When I try to run my program on a 64bit machine I get the following error: System.BadImageFormatException was unhandled Message: Could not load file or assembly TreeTMHook, Version=1.0.2889.19619, ...

Folder size linux

Hi I need to monitor folders on my linux machine periodically to check whether they are exceeding certain limits. I have checked stat function call but running stat recursively on all sub folders and files is time consuming and I need to do this for all folders. Does kernal maintain any datastructures which I can interpret in my progr...

C++: Array of member function pointers to different functions

I have a class A which contains member functions foo() and bar() which both return a pointer to class B. How can I declare an array containing the functions foo and bar as a member variable in class A? And how do I call the functions through the array? ...

C++ Mingw: Two objects of the same class are changing the data across eachother.

I am a newbie. Using class clsMRDateTime and am creating 2 instances of objects in the main code. When I activate the line: clsMRDateTime objMRDateTimeURL("10_05_2011");//THIS CAUSES THE PROBLEM!!!!! It causes the date in the first instance of the class to match the second instance of the class. I checked for static class var...

Qt Application Blocking System Shutdown

Hi, I have a Qt 4.6.2 application, running on a Windows XP SP2 x64 system. When I press the physical power/shutdown button on the system, when my application is running nothing will happen, the app will not close and the system does not Shutdown. If I go to start menu and click shutdown, then my application will close but the system w...

cannot open include file 'afxres.h' in VC2010 Express

hello, i try to compile an old project using VS express 2010 and i get the error: 1>terrain2.rc(10): fatal error RC1015: cannot open include file 'afxres.h'. from this code ///////////////////////////////////////////////////////////////////////////// // // Generated from the TEXTINCLUDE 2 resource. // #include "afxres.h" i have insta...

Is there a book that introduces the Microsoft WDK samples in great detail?

Especially those under Microsoft SDKs\Windows\v7.1\Samples\multimedia\directshow Is there such a book? ...

How to return a 2 dimensional vector ?

I have a function that creates a 2D vector void generate(int n) { vector< vector<int> > V (n, vector<int>(1 << n , 0 )); ....... }//n is used to determine the size of vector Now, I need to return the created vector to use it in another function .If I did return V ; it will be wrong because V is a local variable but I can't ...

Detect roaming (switching the Access Point) with QtMobility?

Hello! I need to write an application, that detects roaming from one access point to another if I'm connected to WLAN. Unfortunately I couldn't find anything that detects roaming for me. All I could find are some explanations in the Bearer API. One sentence says: The second form of roaming is referred to as Forced Roaming. The sys...

Registration-Free COM Objects on Windows-7/64bit

I'm trying to get the Registration-Free Activation of COM Components: A Walkthrough sample from Microsoft to run on a windows 7 Professional / 64bit machine. I've downloaded the demo program MSDNRegFreeCOM.msi. I have it building and running correctly on my XP-32 dev box using VS2008SP1. But when I copy working 32bit demo program to m...

memory usage and minimizing

We have a fairly graphical intensive application that uses the FOX toolkit and OpenSceneGraph, and of course C++. I notice that after running the application for some time, it seems there is a memory leak. However when I minimize, a substantial amount of memory appears to be freed (as witnessed in the Windows Task Manager). When the a...

question about compress header

from this site there is header "compress.h" http://www.fredosaurus.com/notes-cpp/examples/compress/compress.html i am using visual c++ 2010 and also boost library and am interested if there is similary header of compress.h? thanks ...

How to create a type-tag for template specialization

I have a custom logging class that supports iostream-syntax via a templated operator <<: template< class T > MyLoggingClass & operator <<(MyLoggingClass &, const T &) { // do stuff } I also have a specialized version of this operator that is supposed to be called when a log-message is complete: template< > MyLoggingClass & operat...

How does this implementation of chaining exceptions work?

Hello, I previously asked a question about how to chaining exceptions in C++, and one of the answers provided a nifty solution to how it can be done. The problem is that I don't understand the code, and trying to have this kind of discussion in the comments is just too much of a bother. So I figured it's better to start a new question e...

C++ downcast ( using dynamic_cast ) returns NULL ?

Environment: Linux C++ / Qt 4x I do not understand why the following downcast returns NULL? I pasted base and derived class below. Thanks in advance for any tips or suggestions. -Ed void MainWindow::onRtledaEventHandler(fes::EventArgs eventArgs) { // This cast returns a NULL ? fes::AtsCommandEventArgs* atsCommandEventArgs = d...