c++

warning C4003 and errors C2589 and C2059 on: x = std::numeric_limits<int>::max();

This line works correctly in a small test program, but in the program for which I want it, I get the following compiler complaints: #include <limits> x = std::numeric_limits<int>::max(); c:\...\x.cpp(192) : warning C4003: not enough actual parameters for macro 'max' c:\...\x.cpp(192) : error C2589: '(' : illegal token on right side of...

Decent tool/library for C++ to handle XML ?

I need to do some XML-related job (parsing, comparison etc). Is there any C++ library for this that you know works good ? Preferrably for Win XP. Thanks. ...

Tool to create wizards in C++

The MFC concept (using PropertySheet / PropertyPages) to build a wizard has let me down many times and for several reasons. I googled the subject somewhat but could not turn up with any library or tool that would help me create my wizards easier. Any recommendations would help a lot. ...

specializing functions on stl style container types

If i have a type T, what is a useful way to inspect it at compile time to see whether its an STL-style container (for an arbitrary value type) or not? (Assumption: pointers, reference, etc. already stripped) Starting code: template<class T> // (1) void f(T&) {} template<class T> // (2) void f(std::vector<T>&) {} void test() { ...

LibTIFF: Extract all tags from a TIFF image

I'm currently working on a project which requires me to split a TIFF image into a file containing all tags and a file containing all image data and to reconstruct a TIFF image from these files. The only problem is that it seems that LibTIFF provides no easy way to grab all tags from an image. I've tried using TIFFGetTagListCount and th...

DirectX: How do you initialize the vertex buffer and index buffer for a cone?

How do you initialize the vertex buffer and index buffer for a cone in DirectX 9 in C++? ...

Which is better? To use short or int?

In Java or C++: Which is better? To use short or int for numbers that go to the short Max value, from 0 to 65535 in the case of unsigned short in C++. I heard something about using int is better by the processor registers... ...

Change brightness of blitted bitmap using Allegro

I'm using the Allegro game library to make a tile game. I want the tiles to get exponentially brighter. Unfortunately Allegro does not have a "Brighten" feature. What I then decided to do, was blit a tile to the buffer, then for each pixel that it just blited for that tile, I increased their rgb values and putpixel. The big problem with ...

Open Source Executable Editor

I have a native C++ windows app that i would like to edit. Are there any open source tools for me to do this on Windows? I want to edit the executable directly. ...

Unit testing an executable project

Maybe I am not thinking about this correctly. I am starting my second project using unit tests. My first project I rolled my own, for this project I am trying out Boost::test. My question is, what are the proper procedures for unit testing projects that compile into executables? It seems like everything I see out there is for librarie...

Using exceptions to abort series of user inputs - Good? Bad?

Consider a scenario where a console application asks for a series of inputs, one after the other. Each input is validated before proceeding to the next. Now if an input made by the user is invalid, an error message is shown and the user is asked if he/she wants to continue. If the user chooses no, the input process is aborted. If the use...

Supress unused variable warning in C++ => Compiler bug or code bug?

Presently, I am using the following function template to suppress unused variable warnings: template<typename T> void unused(T const &) { /* Do nothing. */ } However, when porting to cygwin from Linux, I am now getting compiler errors on g++ 3.4.4 (On linux I am 3.4.6, so maybe this is a bug fix?): Write.cpp: In member function `vo...

Where in memory is vtable stored?

Where in memory is vtable stored? ...

structure on a heap memory

This question was recently asked to me in an interview for which i went confused!! "How do you initialize a structure in the heap memory ?" could anybody please tell me the correct answer for this? btw:how exactly are stack and heap memory are different from each other? And looking about the above question some might also ask me about ...

array vs vector vs list

I am maintaining a fixed-length table of 10 entries. Each item is a structure of like 4 fields. There will be insert, update and delete operations, specified by numeric position. I am wondering which is the best data structure to use to maintain this table of information: array - insert/delete takes linear time due to shifting; update ...

Overload operators as member operator or non-member operator?

I am currently creating a utility class that will have overloaded operators in it. What are the pros and cons of either making them member or non-member functions? Or does it matter at all? Maybe there is a best practice for this? ...

How to get List of free port number in VC++?

How to get List of free port number in VC++? Aslo i want to check wether user define port number is free or not ? ...

pros and cons of smart pointers

I came to know that smart pointer is used for resource management and supports RAII. But what are the corner cases in which smart pointer doesn't seem smart and things to be kept in mind while using it ? ...

Which STL container to use if I want it to ignore duplicated elements?

I am looking for some STL (but not boost) container, which after the following operations will contain 2 elements: "abc" and "xyz": std::XContainer<string> string_XContainer; string_XContainer.push_back("abc"); string_XContainer.push_back("abc"); string_XContainer.push_back("xyz"); By the way, I need it just in order to call string_XC...

is there a design pattern that isolate 'methods' from member?

basically, i want to have something like: class DataProcessor{ }; however, in the future, i will need to pass DataProcessor's instance to some other functions, because DataProcessor contains some crucial data. what I got in mind is to separate the members from methods: class DataProcessorCore{}; class DataProcessor : public Da...