c++

Do I need multiple template specializations if I want to specialize for several kinds of strings?

For example: template<typename T> void write(T value) { mystream << value; } template<> void write<const char*>(const char* value) { write_escaped(mystream, value); } template<> void write<char*>(char* value) { write_escaped(mystream, value); } template<> void write<const std::string&>(const std::string& value) { writ...

Are there possible approaches to map signal handling (c library) into a c++ exception?

I have a c++ application linked against some c libraries. Are there possible approaches to encapsulate the signal handling in a C++ class, so it could be handled as a c++ exception? ...

What arguments do I pass to the client when running the boost::asio sockets examples

I am learning how to use the boost asio libraries and I am using the UDP examples on visual studio 2008. I have compiled and run the server application(name udp_server.exe). I have tried to run the client application but is does connect to the server. How do I specify the host and service name to the application for it to connect. I have...

How to write a custom predicate for multi_index_containder with composite_key?

I googled and searched in the boost's man, but didn't find any examples. May be it's a stupid question...anyway. So we have the famous phonebook from the man: typedef multi_index_container< phonebook_entry, indexed_by< ordered_non_unique< composite_key< phonebook_entry, member<phonebook_entry,std::string,&...

Problems compiling an external library on linux...

So I am trying to compile the libssh2 library on linux, but when I try to compile the example it comes up with a lot of errors, and even though I include the headerfile it asks for, it still asks for it. Here are the error messages and the resulting messages: ~/ gcc -include /home/Roosevelt/libssh2-1.2.5/src/libssh2_config.h -o lolbais...

C++: Weird Segmentation fault.

I am trying to print something using C++. However, I am running into a strange bug that has left me clueless, I use the following code: PRINTDLG pd; ZeroMemory(&pd, sizeof(pd)); pd.lStructSize = sizeof(pd); pd.Flags = PD_RETURNDEFAULT; PrintDlg(&pd); // Set landscape DEVMODE* pDevMode = (DEVMODE*)GlobalLock(pd.hDevMode); pDevMode->dmOr...

MFC , C++ in embedded(semiconductor) projects

What are the internal features/aspects of C++/ VC++ and MFC that are used for embedded(semiconductor) projects by large IT companies. I ask this becuase I need to be prepared for one such poistion. please reply. ...

getting cpu usage of one process using c++ (win32)

How i get the cpu of one process (by its id or som thing like that...) using c++ lang. ...

Not all symbols of an DLL-exported class is exported (VS9)

I'm building a DLL from a group of static libraries and I'm having a problem where only parts of classes are exported. What I'm doing is declaring all symbols I want to export with a preprocessor definition like: #if defined(MYPROJ_BUILD_DLL) //Build as a DLL # define MY_API __declspec(dllexport) #elif defined(MYPROJ_USE_DLL) //Use a...

Sealing a class

Possible Duplicate: Why seal a class? Why would I want my class to be sealed? Somehow it does not make sense to me. If someone want to inherit from my class that's his/her business and I have no desire to poke my nose in it. It somehow sounds artifficial to me and it seems that it is somehow against code reuse. Why would anyon...

How to connect GraphEdit to my app's graph

I am trying to figure out how to get GraphEdit to show me my running graph from my app. I running windows 7 64bit. In the directshow sdk samples they have a spot for registering with the rot. I read on M$'s site that I needed to register the droppage.dll(cant recall the exact name right now). So I did that, but still no dice. Any id...

c++/boost: use tuple ctors when subclassing

Hi there, is there some way to use a boost tuple's ctors as an addition to the subclass methods (and ctors) like here? // typedef boost::tuple<int, SomeId, SomeStatus> Conn; // Conn(1); // works and initializes using default ctors of Some* struct Conn : boost::tuple<int, AsynchId, AccDevRetStatus> {}; Conn(1); // "no matching function ...

consts and other animals

Hello i have a cpp code wich i'm having trouble reading. a class B is defined now, i understand the first two lines, but the rest isn't clear enough. is the line "B const * pa2 = pa1" defines a const variable of type class B? if so, what does the next line do? B a2(2); B *pa1 = new B(a2); B const * pa2 = pa1; B const * const pa3 = pa2;...

QT - How to apply a QToolTip on a QLineEdit

On a dialog I have a QLineEdit and a button. I want to enable a tool tip for the QLineEdit(in it or under it) when I press the button. Please give me a code snippet. ...

how-to add "warnings as error" rule to Qt .pro file ?

Hi, When I usually work on a C++ project, one of the first things I do is setting up the "treat warning as errors" on my compiler. When using Qt, qmake generates the Makefile for you and doesn't include this option on the compilation commands. I'm pretty sure there is a way to add such an option (and others) into the generated Makefile...

If-elseif-else Logic Question

I have a set of three values, call them x, y, and z. If value A happens to match only one in the set x, y, and z, then that means we have a proper match and we stop searching for a match, even if it is at y. It can match any one in that set. These values x, y, and z are non-constant so I cannot use a switch-case statement. How do I do ...

Segfaults with singletons

Hello, I have such code: // Non singleton class MyLogManager { void write(message) {Ogre::LogManager::getSingletonPtr()->logMessage(message);} } class Utils : public singleton<Utils> { MyLogManager *handle; MyLogManager& getHandle { return *handle; } }; namespace someNamespace { MyLogManager &Log() { return Utils::get_mutab...

What exactly does -march=native do?

Gentoo Wiki told me the following: Warning: GCC 4.2 and above support -march=native. -march=native applies additional settings beyond -march, specific to your CPU. Unless you have a specific reason not to (e.g. distcc cross-compiling), you should probably be using -march=native, rather than anything listed below. What a...

VMRMixerControl9 & GDI problem!

I'm attempting to overlay a bitmap on some video. I create a bitmap in memory, then I call SelectObject to select it into a memoryDC, so I can perform a DrawText operation on it. I'm not getting any results on screen at all - can anyone suggest why? thanks HRESULT MyGraph::MixTextOverVMR9(LPCTSTR szText) { // create a bitmap object...

Why this Explicit P/Invoke does not work ?

The following .net to native C code does not work, any ideas extern "C" { TRADITIONALDLL_API int TestStrRef( __inout char* c) { int rc = strlen(c); std::cout << "the input to TestStrRef is: >>" << c << "<<" ; c = "This is from the C code "; return rc; } } [DllImport("MyDll.dll", SetLastError = true)] static ext...