c++

MFC - precompiled header and AFX_IMPORT_DATA

Hi, I had a project under MFC 7.0 and now I created new project under MFV 9.0. I copied all the files, did the relevant changes in generated files (Doc, view, resources etc.) and when I try to build to project, the compiler outputs the following error: Error 1 error C2146: syntax error : missing ';' before identifier 'CUserTools...

Recompile MFC DLL while client exe is running

Is it possible to recompile an MFC DLL while its "client" executable is running, and have the executable detect and pick up the new changes? If it's possible, is it foolish? Being able to recompile the DLL without restarting the exe would save some time in my coding workflow. I am using Visual Studio 2008, code is written in native C++/M...

C++ iostreams question

Hello! I am now diving into boost::iostreams and I'm looking for a way to create a stream that iterates over some container<char>. Right now I have the code that work for a std::vector<char>, but it does ONLY for it, because I wrote std::vector-specific code. I am doing the following thing: template <class Object, class Container> vo...

multimap accumulate values

I have a multimap defined by typedef std::pair<int, int> comp_buf_pair; //pair<comp_t, dij> typedef std::pair<int, comp_buf_pair> node_buf_pair; typedef std::multimap<int, comp_buf_pair> buf_map; //key=PE, value = pair<comp_t, dij> typedef buf_map::iterator It_buf; int summ (int x, int y) {return x+y;} int total_buf_size = 0; std::c...

Is codeblocks 10.05. compatible with QtWorkbench ?

windows xp sp2 , codeblocks 10.05. , Qt 4.6 Does anyone know if codeblocks_10.05 is compatible with QtWorkbench-0.6.0_alpha. I made everything written on http://code.google.com/p/qtworkbench but when I go to compile, codeblocks freeze. I may have made a mistake somewhere in the setup, I do not know. The main question: Is it even CB 10:...

wchar_t pointer

What's wrong with this: wchar_t * t = new wchar_t; t = "Tony"; I thought I could use a wchar_t pointer as a string... ...

Recommendations on multiple types of games server

Hi, I've already developed some online games (like chess, checkers, risk clone) using server side programming (PHP and C++) and Flash (for the GUI). Now, I'd like to develop some kind of game portal (like www.mytopia.com). In order to do so, I must decide what is a good way to structure my server logic. At first I thought in programming...

Create a DataTable from list<T> and bind it to datagridview [c++]

Hi guys, I'm new with c++/cli programming. I have to do a program for the university I'm trying to create a datatable in c++/cli with visual c++ 2010 and then bind to dataGridView1. I have a list of Class P object with several fields. I've looked every where, but i've found only c# versions. Thank you in advance, and sorry for my eng...

reference variables in c++

this might be silly!!! but i am eager to know about it:) why are reference variables not present/used in C? why are they designed for C++? ...

C++ implicit conversions and ambiguity in overloaded function call

I am facing the following problem: I have a class V (say a vector) from which I can produce two classes: CI and I (think of const_iterator and iterator). If I have a const V then I can only produce CI (again think of iterator and const_iterator). Essentially I would like to subsitute (const V& v) with (CI ci) and (V& v) with (I i). Mor...

C++: Expected a declaration (compiler error C2059)

The following is giving me a compiler error: #include <foo.h> #define ODP ( \ L"bar. " \ // C2059 here L"baz.") #define FFW (5) What am I doing wrong? ...

How to get nmake to push through errors ( behaviour of make -k)

I'm using cmake to generate an nmake build system using the "NMake Makefiles" generator. When I compile, even if I specify "nmake /K", the build stops after the first .cpp file which had an error. I understand that it should not compile targets who have a failed dependency, but several independent source files should be handleable in t...

How can I get the compiler tell me what file #define a value?

My code is linking against several other libraries that are also developed at my company, one of these libraries is redefining several values from errno.h, I would like to be able to fix this, however I am having trouble finding the exact file that is redefining these values, I am want to know if there is a way to make the compiler tell ...

fscanf / fscanf_s difference in behaviour

I'm puzzled by the following difference in behaviour: // suppose myfile.txt contains a single line with the single character 's' errno_t res; FILE* fp; char cmd[81]; res = fopen_s(&fp, "D:\\myfile.txt", "rb" ); fscanf(fp,"%80s",cmd); // cmd now contains 's/0' fclose(fp); res = fopen_s(&fp, "D:\\myfile.txt",...

Function that returns a pointer to const 2-d array (C++)

I'm an intermittent programmer and seem to have forgotten a lot of basics recently. I've created a class SimPars to hold several two-dimensional arrays; the one shown below is demPMFs. I'm going to pass a pointer to an instance of SimPars to other classes, and I want these classes to be able to read the arrays using SimPars accessor fun...

trying to see if vector<string> has no values in map<string, string>

Hi Guys, Just for fun I was trying to write a one line with std::find_if with boost::bind to check whether all the keys given in a vector in a map has no values, but really could not come up with a neat line of code. Here is what I attempted vector<string> v; v.push_back("a"); v.push_back("2"); ... map<string, string> m; m....

extraneous empty lines when reading from an ifstream

In my program, I've redirected stdout to print to a file 'console.txt'. A function writes to that file like this: void printToConsole(const std::string& text, const TCODColor& fc, const TCODColor& bc) { // write the string cout << text << "@"; // write the two color values cout << static_cast<int>(f...

Create a C++ container that contain the filenames within a directory

I need to generate a container of filenames within a directory in C++ and it must be cross platform compatible. Someone recommended using the WIN32_FIND_DATA data structure. Is this the best option and if so how would I implement it? The user will not enter the filenames, but rather the C++ function will automatically search the directo...

Is it possible to convert vb.net source to C++ ?

Are there any tools converting vb.net source to C++ eg gnu C++. I know that Mono can transfer the projects to different platforms but i would rather prefer to convert the source. Since all we know that .net uses its own binary libs not available to other complilers is there any tool at least converting vb.net to C++ .net? Thanks in adv...

How to create map<string, class::method> in c++ and be able to search for function and call it?

I'm trying to create a map of string and method in C++, but I don't know how to do it. I would like to do something like that (pseudocode): map<string, method> mapping = { "sin", Math::sinFunc, "cos", Math::cosFunc, ... }; ... string &function; handler = mapping.find(function); int result; if (handler != NULL) result = (int) ...