c++

How to configure Vim for C++ development?

I'm learning C++ using Vim as editor on Windows XP, however I found issue that I have list below. I have downloaded and installed c.vim and it essential file, however when I start vim it show message C/C++ template file 'C:\Program Files\Vim\vimfiles\c-support/templates/Templates' does not exist or is not readable, I want to know how t...

using C++ IO istream object to read is resulting in infinite loop.

The below function results in infinite loop if a string is entered as input. istream & inputFunc(istream &is) { int ival; // read cin and test only for EOF; loop is executed even if there are other IO failures while (cin >> ival, !cin.eof()) { if (cin.bad()) // input stream is corrupted; bail out ...

interview questions - little help

i ran into thos quesiton in a google search.... they look pretty common, but i couldn't find a decent answer. any tips/links ? 1.Remove duplicates in array in O(n) without extra array 2.Write a program whose printed output is an exact copy of the source. Needless to say, merely echoing the actual source file is not allowed. ...

negative precision values in ostream

This is more of a question of curiosity but does anyone know how negative precision values are handled in C++? For example: double pi = 3.14159265; cout.precision(-10); cout.setf(ios::fixed, ios::floatfield); cout << pi << endl; I've tried this out and using GCC and it seems that the precision value is ignored but I was curious if ...

AntiAlias failed when draw string with certain angle in GDI+

I am using the following code to draw Strings. In GDI+ Graphics tempFontGr(XXX); Matrix* myPathMatrix = NULL; myPathMatrix->Rotate(GetDCAngle(), MatrixOrderPrepend); cantempFontGr.SetTransform(myPathMatrix); tempFontGr.SetInterpolationMode(InterpolationModeHighQuality); tempFontGr.SetSmoothingMode(SmoothingModeAntiAlias); tempFontGr.Dr...

How to make an ambiguous call distinct in C++?

void outputString(const string &ss) { cout << "outputString(const string& ) " + ss << endl; } void outputString(const string ss) { cout << "outputString(const string ) " + ss << endl; } int main(void) { //! outputString("ambigiousmethod"); const string constStr = "ambigiousmethod2"; //! outputString(constStr); } //...

What is a good way of sending data as strings through sockets?

Hi As there several ways to exchange data in the form of strings over sockets, such as e.g: using functions like: 1) sprintf() and sscanf() 2) snprintf() and sscanf() 3) printf() and strtof() or converting to char and then pass it as an array I would appreciate if you could suggest which way and why is efficient and better than ot...

Which install system to pick when deploying to Windows and Linux?

My company is thinking of dumping InstallShield and move to something else, mainly because of the poor experience it had with it, mostly on Linux. Our product is a C++ application (binaries, shared libraries) targeted at Windows and Linux (Red Hat). The installer itself isn't required to do anything special, just dump some binaries and...

Magick++ animation generation via SDL pixel data

I'm trying to generate ImageMagick images from SDL pixel data. Here's what the GIF looks like so far. (This GIF is slower than the one below on purpose.) Here's what it's supposed to look like. Notice in the above image that the pixels seem to be overlayed on top of other pixels. Here's where the GIF is actually created. void Drv...

Why do C++ allow constant to be transformed to reference argument in another method?

void outputString(const string &ss) { cout << "outputString(const string& ) " + ss << endl; } int main(void) { outputString("constant tranformed to reference argument"); //! outputString(new string("abc")); new only return pointer to object return 0; } Since its prohibited to create temporary object reference transform...

Are there any tools for compile time checking of asserts in c++?

I was writing a function in c++ the other day and it occured to me the compiler could do a lot more to help me guard against mistakes. The essentials of my code were like this - void method(SomeType* p) { assert(p != 0); p->something(); } And it was called like this SomeType p = NULL; if (SomeCondition) { p = some_real_va...

istream from file_descriptor_source (boost::iostreams) or file

I need to do something like this for my program's input: stream input; if (decompressed) input.open(filepath); else { file_descriptor=_popen("decompressor "+filepath,"r"); input.open(file_descriptor); } input.read(...) ... I can see 1 solution... to use _popen in both cases and just copy the file to stdout if it's already ...

Access violation when exporting a C++ class to Lua using LuaBind

I'm trying to export a simple class to Lua using LuaBind. I took the code from two sites which showed roughly the same way to do it, but it's still failing. // Default headers #include <iostream> #include <string> // Lua headers extern "C" { #include "lua.h" #include "lualib.h" #include "lauxlib.h" } #include "luabind/luab...

What's a good project tailored to learning strengths of Unix / Linux

I've been developing Microsoft Windows based applications (both desktop and web) for several years using C#, .net, & Visual Studio with a dash of C/C++ & WIN32. I want to broaden my horizons and try out developing in a *NIX environment e.g. using Vim & C++. I have limited UNIX experience from a few school projects. I'm having trouble ...

MFC basic structure questions

There are few things I'm not sure of : When you create a basic SDI using MFC app wizard (let's call it TestMfc) you get : 4 major classes : CTestMfcApp CTestMfcView CTestMfcDoc CMainFrame What I noticed is that CTestMfcApp has those declaration ON_COMMAND(ID_APP_ABOUT, &CTestMfcApp::OnAppAbout) // Standard file based document c...

Can Global Arrays in C++ Break Binary Compatibility?

Say a shared library contains the following lines: const char* const arr[] = { "one", "two", "three" }; 1) Can an application link to this library and use the symbol "arr"? 2) Is binary compatibility broken if a new element is added to the definition? 3) How about if one of the string literals is changed? 4) Why (not)? Cheer...

What is a good way to connect multiple clients to the server?

Hi, As there are serveral ways of connecting multiclients to the server such as: fork, select, threads, etc. I would be glad if you could describe which is better to connect multiple clients to the server? Thanks for you time and reply? ...

How to pass data from client to server when using gSOAP ?

I am trying to exchange data between client and server using gSOAP. Actually, I succeeded to send data from client to server but not from server to client. So, could someone please explain what functions to use to pass data from server to client? Thanks for your time and replies, ...

NTL library in Dev-C++

Hi, I want to write a program which use NTL library under Dev-C++. Could tell me how to add NTL libraries to Dev-C++? I tried to compile (as it was said in NTL tutorial) all the files form src catalog in Dev-C++, but I got such a communicate: [Bulid Error] [Project1.exe] Error 255 That's why I cannot get ntl.a file... ...

What is the difference between soap_new() and soap_copy()?

What is the difference between: thread_envs[i] = soap_copy(&env); and thread_envs[i] = soap_new(); Sould we use one of them or both? ...