c++

While loop, doesn't seem to do anything?

Hi there i'm trying to make a function in C++ that takes a number, i, and decides if it is a prime number or not by running through a loop to find it's multiples, and then makes sure it isn't prime through a series of test. However, it seems the loop isn't even being run through. I've told it to output no matter where in the loop it is, ...

Can we execute rightclick without using pCmdInfo->lpVerb

I am not agnaist using pCmdInfo->lpVerb but my problem is how will we handle the situation when we create the rightclick submenus dynamically. For example, I have the following scenario: if(strcmp(cRegKeyVal,"Connected")==0) { //g_bConnectStatus=TRUE; InsertMenu ( m_hSubmenu , 0, MF_BYPOSITION|MF_GRAYED, m_uCmdID++,...

difference between static_cast<const A>(*this) and static_cast<const A&>(*this)

in the following code ( taken from effective C++ ): class A { .... .... .... char& operator[](std::size_t position) // now just calls const op[] { return const_cast<char&>( // cast away const on // op[]'s return type; static_ca...

C++ JMS client or C++/C SOAP Client

I have an application in C++, but it'll need to 'talk' to Java based message-service. In the past we used WebSphere MQ and used their C++ libraries to do the 'talking'. So I am in search of (ideally) free C++ to Java solution which doesn't hold the whole JVM in memory. The other option I've looked into is SOAP. I've looked into Axis2...

Getting pointer to bottom of the call stack and resolving symbol by address (like dladdr) under Windows?

I want to implement an analog of backtrace utility under windows in order to add this information to exception for example. I need to capture return addresses and then translate it into symbols names. I'm aware of StackWalk64 and of StackWalker project but unfortunately it has several important drawbacks: It is known to be very slow ...

Escaping double quotes and the Web

I am trying to get the following sent in an xml. <Request xmlns="http://abc.org/1.1/Listener.wsdl"&gt;&amp;lt;serverstatusinquiry xmlns="http://abc.org/messages"/&amp;gt;&lt;/Request&gt; The problem I am facing is the text part of the Request node. I am printing the text as follows. "<serverstatusinquiry xmlns=\"http://abc.org/messag...

Modularity: Using Interfaces or not?

Since a few years, common sense seems to dictate that it's better to program against interfaces rather than against implementations. For high-level code this indeed seems logical, e.g. if I have a complex solver in my application, it seems better to have something like this: ISolver *solver = solverFactory.getSolver(); solver->solve(in...

compile c++ project on ubuntu

hi all, i'm writing my c++ project and in visual studio everything goes good but when i'm compiling it on ubuntu many things get wrong. example: int main (int argsNum, char* args[]){ Country* country = new Country("USA"); Military* military = new Military("Army",country); Shalishut* shalishut = new Shalishut(military); ...

Reading VertexDuplicationIndices template from D3DX mesh .x file

I need to read the duplicates chunk from an .x file. .x file can be saved in text format, I wrote a tool that generates meshes and saves them in x files, I found that if I'm generating the x file with duplicates, and calculate the adjacency info, and passing it to the save function, it will save a chunk with the duplicates. pMesh->Gene...

Linking of Method calls

I had to define a new set of wrappers for existing methods. These new wrappers intend to help in debugging by including certain tracing information. Original Source Code: Sample.c :: Caller{ void functionA(){ funcB(); } } Callee{ void funcB(){ } } Modified Code with Traditional Wrapper Functionality: Sample.h :: #define fu...

Difference between preprocessor directives #if and #ifdef

What is the difference (if any) between the two following preprocessor control statements. #if and #ifdef ...

What are primitive types default-initialized to in C++?

When I use an initialization list: struct Struct { Struct() : memberVariable() {} int memberVariable; }; the primitive type (int, bool, float, enum, pointer) member variable is default-initialied. Is the value it gets implementation defined or is it the same for all implementations? ...

How to print content of a QGraphicsView

How can I print the content of a QGraphicsView in Qt? Thanks a lot. ...

How to Handle Database Connections in Qt?

Here my problem; in such a case it complains about duplicate connections with same connection name: Test::Test(QString connectionName) { db=QSqlDatabase::addDatabase("QMYSQL",connectionName); } int main(int argc, char *argv[]) { QString connectionName=QString("test"); QCoreApplication a(argc, argv); Test myDb(connecti...

How to capture stdout/stderr with googletest?

Is it possible to capture the stdout and stderr when using the googletest framework? For example, I would like to call a function that writes errors to the console (stderr). Now, when calling the function in the tests, I want to assert that no output appears there. Or, maybe I want to test the error behaviour and want to assert that a ...

Question about const_cast in c++

Hi,all: this is quoted from Effective C++ 3rd editiion const_cast is typically used to cast away the constness of objects. It is the only C++-style cast that can do this. My question is can const_cast add constness to a non-const object? Actually i wrote a small programme trying to approve my thought. class ConstTest { public:...

How can I perform network IO at the very end of a process' lifetime?

I'm developing a DLL in C++ which needs to write some data via a (previously established) TCP/IP connection using the write() call. To be precise, the DLL should send a little 'Process 12345 is terminating at 2007-09-27 15:30:42, value of i is 131' message over the wire when the process goes down. Unfortunately, all the ways I know for ...

Stuff a class with user-defined constructors into a union

class Foo { Foo(int val) { /* Do some initialization */ } Foo() { /* Do nothing */ } }; union Bar { Foo foo; }; That code generates this error: error C2620: member 'Bar::foo' of union 'Bar' has user-defined constructor or non-trivial default constructor I understand why you'd throw that error if the constructor actually d...

List initializer

I am trying to declare an iterator of type std::initializer_list as it is described in this answer. But I always get this error: error: 'iterator' is not a member of 'std::initializer_list<int>' May someone guide me how to declare an iterator of type std::initializer_list? EDIT: This code for example will not work. In addition, The...

VC++ CRT Redist problem

Hi, I've developed a 64 bit dll using C++ and Visual Studio 2008 and i'm trying to register it on a target machine using 'regsvr32.exe'. I've checked the manifest file and it clearly states what version of CRT is needed: <assemblyIdentity type='win32' name='Microsoft.VC90.CRT' version='9.0.21022.8' processorArchitecture='amd64' public...