c++

List of all hosts on LAN network

How can I get all the IP addresses and associated host names in a LAN? ...

Default Constructors

I know that default constructors initialize objects to their default values, but how do we view these values? If there's a variable of type int, it is supposed to be initialized to 0. But how do we actually view these default values of the constructors? Can anyone please provide a code snippet to demonstrate the same? ...

where is socket header in linux

I compile my simple prog with #include <sys/socket.h> but there's none of this file. Where is it, I just start coding in linux and I have no idea where is it . Or do we need to download it online . ...

Predicting voice packets (speex/ilbc c++)

Hello, For some time I've been using gsm codec for network audio chat. Now I'd like to implement smth like speex or iLBC due to "voice prediction". As far as I understand i need timestamps for packets. Also I know that to make codec to predict voice I have to pass it NULL packet for example. But I cannot understand the entire concept!...

C++: Datatypes, which to use and when?

I've been told that i should use size_t always when i want 32bit unsigned int, i dont quite understand why, but i think it has something to do with that if someone compiles the program on 16 or 64 bit machines, the unsigned int would become 16 or 64 bit but size_t wont, but why doesnt it? and how can i force the bit sizes to exactly what...

Extend a application with out changing main method?

I need to extend several class in my c++ application without changing any code in application. (Product extend as a solution). Is there a specific design pattern to do that? ...

Forward declaration just won't do.

Below are two fragments (ready to compile) of code. In first fragment in which I'm using only forward declaration for a struct while deleting pointer to this struct from a Base class dtor for a Guest class isn't invoked. In the second fragment when instead of forward declaration I use full definition of this Guest class using delete in B...

symbol table for debug in windows

Hello, I want to compile and use Visual studio for checking an unmanaged C++ on windows program. I am using ADPlus and WinDBG. For doing this I need a .pdb file amd to configure the symbols of my debugging. How u can configure it (to local machine and not the net) ? ...

Should methods that implement pure virtual methods of an interface class be declared virtual as well?

I read different opinions about this question. Let's say I have an interface class with a bunch of pure virtual methods. I implement those methods in a class that implements the interface and I do not expect to derive from the implementation. Is there a need for declaring the methods in the implementation as virtual as well? If yes, why...

Can anyone help me interpret this simple disassembly from WinDbg?

Hi friends, I got the following simple C++ code: #include <stdio.h> int main(void) { ::printf("\nHello,debugger!\n"); } And from WinDbg, I got the following disassembly code: SimpleDemo!main: 01111380 55 push ebp 01111381 8bec mov ebp,esp 01111383 81ecc0000000 sub esp,0C0h 01111389 53 ...

How to get the number of elements in a struct?

Hello, I declared a struct for some options that shall be filled by command line arguments or by reading an input file: struct options { int val1; int val2; bool val3; } Now I want to check for the correct number of arguments at execution of the program. Sure thing a const int optionsSize = 3; would do. But is there any ada...

JNI C++ Debugging Techniques?

I have a Linux C++ application that creates a JVM and makes JNI calls. I am new to JNI, and so far I the only effective way I have found to debug my application during development is by trial and error. What are some techniques to use to debug the infamous "A fatal error has been detected by the Java Runtime Environment" Java VM crashe...

Odd error with C++ class template

Hi guys, can anyone suggest why this does not compile? I guess I'm missing something major here. The compiler is g++ 4.2.1 (on OS X) and error is "expected `;' before ‘it’" on the line where the iterator is declared. #include <vector> template <class T> class A { public: struct SomeStruct { T* ptr; int i; }; ...

How to convert from const char* to unsigned int c++

Hi, I am new in c++ programming and I have been trying to convert from const char* to unsigned int with no luck. I have a: const char* charVar; and i need to convert it to: unsigned int uintVar; How can it be done in C++? Thanks ...

qt QWidget click

Hello, I have my own class based in QWidget. I put this widget in QMainWindow and i need catch mouse click on this widget. I try: connect(my_widget,SIGNAL(clicked()),this,SLOT(exit(0))); But nothing happening. How can i do it? Thank you ...

Boost.MPI: What's received isn't what was sent!

I am relatively new to using Boost MPI. I have got the libraries installed, the code compiles, but I am getting a very odd error - some integer data received by the slave nodes is not what was sent by the master. What is going on? I am using boost version 1.42.0, compiling the code using mpic++ (which wraps g++ on one cluster and icpc o...

Simplest way to interrupt a thread that is blocked on running a process

I need to execute some commands via "/bin/sh" from a daemon. Some times these commands takes too long to execute, and I need to somehow interrupt them. The daemon is written in C++, and the commands are executed with std::system(). I need the stack cleaned up so that destructors are called when the thread dies. (Catching the event in a C...

Direct access to memory devices under Windows / Linux

Hello I'm currently writing a software to test the integrity of flash-memory devices. (using c++ iostreams) To achieve this goal files with random content are written to the device, read back, copied, moved, compared ( I put the device under stress condition, and check if the data is valid from time to time)... Everything looks great on...

Passing more than one variable to ExecMethod

I am trying to call wmisetbrightness, but it takes two inputs. How do I pass more than one input to ExecMethod? Code snippet below is obviously wrong. // set up to call the WmiSetBrightness Method BSTR MethodName = SysAllocString(L"WmiSetBrightness"); BSTR ClassName = SysAllocString(L"WmiMonitorBrightnessMethods"); IWbemClassObject* pC...

Draw with QPainter

Hello, I need draw with QPainter, but when i try to do it not in void paintEvent(QPaintEvent *) I catch error: QPainter::setPen: Painter not active QPainter::setBrush: Painter not active Can i use qpainter not in void paintEvent(QPaintEvent *) ? Thank you. ...