c++

Why insert from std::map doesn't want to update? [C++]

Hi, I'm trying to insert multiple times this same key into map but with different values. It doesn't work. I know that operator[] does this job, but my question is, if this behaviour of insert is correct? Shouldn't insert() inserts? I wonder what standard says. Unfortunately I don't have it(Standard for C++) so I can't check. Thank you f...

Can Pointer to reference and Pointer to the actual variable be treated as same?

I recently saw the below code ( simplified version given below) in my code base and got this doubt: class B; class A { public: A():m_A("testA"){} B& getB() { return m_B; } B* getBPtr() //== > written to explain the problem clearly { return &m_B; } private: B m_B; }; class B { pub...

Code::Blocks: How to run within IDE?

When I ask CodeBlocks to run my built application it spawns a terminal window and runs the application within that window. How do I instead get it to run within the IDE's log window? ...

using tapi to monitor multiple phones and dial or hangup

I have with a good level of success got a C# application to use TAPI to connect to my office PBX and dial and hangup calls but need to go further and be able to monitor activity and provide CTI to client pc's as well as integration back to my companies web based CRM. I am focusing on the client app for CTI popups and dial/hangup functio...

Why is the type library in my dll corrupt (registering returns TYPE_E_CANTLOADLIBRARY)?

We have a mature c++ COM codebase that has been building, registering and running for many years. This includes numerous developer machines and autobuild machines. The codebase builds several dlls and exes. Some of these are COM servers. The typical setup is Xp64 using both visual studio 2005 and 2008. We have both 32 bit and 64bit ...

Simple tool for callgraph in C++

Hi there! Is there are simple tool, which can be used to determine from where a function is called, which other function the function calls ...? Edit: I'm using Mac OS X (10.6) and just want to do static analysis. Thanks! ...

c++ why is constructor in this example called twice?

Hi! I just try to understand the behaviour of the following situation: template <typename T1> struct A{ template <typename T2> A(T2 val){ cout<<"sizeof(T1): "<<sizeof(T1)<<" sizeof(T2): "<<sizeof(T2)<<endl; } T1 dummyField; }; so - the class is templated with T1 and the constructor is templated with T2 now - ...

Communication between processes

I'm looking for some data to help me decide which would be the better/faster for communication between two independent processes on Linux: TCP Named Pipes Which is worse: the system overhead for the pipes or the tcp stack overhead? Updated exact requirements: only local IPC needed will mostly be a lot of short messages no cross-...

c/c++ passing argument by pointer / argument by reference stackframelayout?

hi! foo1(int* val){(*val)++;} foo2(int &val){val++;} will the compiler create in both cases the same code? will it simply write a pointer into the parameterpart of foo's stackframe? or will in the second case the callers' and foos' stackframes somehow overlap such that the callers' local variable takes the same memory on the stack as...

Not receiving WM_PAINT message when returning from Security Screen (Ctrl+Alt+Del) in Windows7

I need to detect the closing of the security screen, this is the full screen that appears when a user presses Ctrl+Alt+Del under windows. In Xp my application receives an wm_paint message when this screen is closed but under windows 7, a message is not always received, maybe only 25% of the time. I tried catching the the WM_WTSSESSION...

Copy constructors and Assignment Operators

I wrote the following program to test when the copy constructor is called and when the assignment operator is called: #include class Test { public: Test() : iItem (0) { std::cout << "This is the default ctor" << std::endl; } Test (const Test< "This is the copy ctor" << std::endl; } ~Test() ...

parallel Bubble sort ....please HELP...

i write a c++ code for Bubble sort algorithm and i dont know how to make it parallel using openmp so please help me ..... this is the code : #include "stdafx.h" #include <iostream> #include <time.h> #include <omp.h> using namespace std; int a[40001]; void sortArray(int [], int); int q=0; int _tmain(int argc, _TCHAR* argv...

List of standard header files in C and C++

Where could I find the list of all header files in c/c++? While I am building a library I am getting an error like tree.h not found. I suppose this is a standard header file in c/c++. This raised in me the curiosity to know all the header files and their contribution. Is there a place I can search for? I am working on Solaris Unix. ...

STL-friendly pImpl class?

I am maintaining a project that can take a considerable time to build so am trying to reduce dependencies where possible. Some of the classes could make use if the pImpl idiom and I want to make sure I do this correctly and that the classes will play nicely with the STL (especially containers.) Here is a sample of what I plan to do - d...

Merge columns in Excel using Visual c++

I would like to know how can we merge any two colums(cells) and have text on the merged columns in MS Excel programmatically using C++. We are using Microsoft Visual Studio 2008. The function we use for Excel operations is Autowrap();, e.g.: AutoWrap(DISPATCH_PROPERTYGET, &result, pXlSheet, L"Range", 1, parm); in place of range I tr...

Qt use-case for same signal to 2 slots on same object?

I am a total newbie to Qt. As I was reading the documentation, I came across this configuration: connect( Object1, Signal1, Object2, slot1 ) connect( Object1, Signal1, Object2, slot2 ) What could possibly be the use-case for this? Looks odd to me coming from an Erlang/Python background. It must have to do with C++ inheritance twists ...

How does Google Maps know my position?

I have a nokia 5500 sport mobile phone, and I found after i installed google map, it can automatically locate to my current position. and I want to know how google map get my position and mark it on the map ? How can I programming implement this feature with symbian C++(nokia 5500 's operate system is Symbian 3rd). ...

Logic differences in C and Java

Compile and run this code in C #include <stdio.h> int main() { int a[] = {10, 20, 30, 40, 50}; int index = 2; int i; a[index++] = index = index + 2; for(i = 0; i <= 4; i++) printf("%d\n", a[i]); } Output : 10 20 4 40 50 Now for the same logic in Java class Check { public static void main(String[] ar) { int ...

c++ Garbage collection and calling destructors

Per-frame I need to allocate some data that needs to stick around until the end of the frame. Currently, I'm allocating the data off a different memory pool that allows me to mark it with the frame count. At the end of the frame, I walk the memory pool and delete the memory that was allocated in a particular frame. The problem I'm runn...

SSL_CTX_use_PrivateKey_file fail under Linux

I'm trying to use the SSL_CTX_use_PrivateKey_file function in OpenSSL under Linux, but it returns false. The surrounding code has been ported from Windows, where everything runs fine. Is there something that must be done differently depending on system? I've compiled the OpenSSL library myself (default config etc) under Ubuntu and am us...