c++

glibc under windows

Is it (or would it) be possible to use glibc under windows (as a replacement of msvcrt)? I knwo this is a stupid question, and answers like cygwin will pop up, but I am really asking: is it possible to link to glibc on windows and use all library functions like with msvcrt? ...

Deserializing unknown inherited type [C++]

Hey Lets say I have a class which routes messages to their handlers. This class is getting the messages from another class who gets the messages through socket. So, the socket gets a buffer containing some sort of message. The class that routes the messages is aware of the message types. Every message is inheriting Message class which ...

Using Function Templates

I have created a structure of different data types and i want to return each type of data. does this can be done using a function template which takes a different data argument not included in structure or no arguments? I have something like this, struct mystruct{ int _int; char _c; string _str }; In function template(int i) { my...

Flex -- C++ connection ?

Hi. How do I connect a Flex Application( Internet Site ) and C++ togehter ? a minimalistic example from what i mean (User Story): Frank goes to www.myflexsite.de there are 2 textboxes and 1 Button( Label = add two numbers) . He inserts 2 in the first textbox and 5 in the ohter. Now he clicks on the add button. The Backend : We have a ...

how to build dll files in netbeans using ms vc++ compiler ?

i tried using cygwin gcc compiler along with netbeans to create dll files it seems there is an issue in the generated dll file. if i use the ms vc++ compiler and do all compiling on command line its runs file, but i dont know how to integrate ms vc++ tools in netbeans ... can anyone help me on that ? thanks jay ...

In SASL authentication, are the messages between a particular client and server the same every time it connects?

I wrote a test client and server using the Cyrus SASL library, and I'm manually forcing it to select GSSAPI as the mechanism. While debugging, I printed the md5sum of each message as it was passed between the two. I noticed that the sequence seems to be the same every time I connect. That is, if the message sequence on the first negot...

Why doesn't this << overload compile

I can't figure out why the following code doesn't compile. The syntax is the same as my other operator overloads. Is there a restriction that the << overload must be friended? If so, why? Thanks for any help. This doesn't work - #include "stdafx.h" #include <iostream> #include <fstream> #include <string> class Test { public: explici...

Not using iterators into a resized vectors

I read in The C++ Programming Language : Special Edition Don't use iterators into a resized vector Consider this example. vector< int >::iterator it = foo.begin(); while ( it != foo.end() ) { if ( // something ) { foo.push_back( // some num ); } ++it; } Is there a problem with this? After the vector was resized, would the...

what's interface vs. methods, abstraction vs. encapsulation in C++

Hi, I am confused about such concepts when I discussed with my friend. My friend's opinions are 1) abstraction is about pure virtual function. 2) interface is not member functions, but interface is pure virtual functions. I found that in C++ primer, interface are those operations the data type support, so member functions are in...

C++ function call with the parameters unknown at compile time

As weird as it sounds, I need to call a function in C++, for which I do not know the signature. Basically, I want to let the user specify a list of arguments, and argument types, and then attempt to call a given function with these arguments. I would then like to know if the function call worked or not, and if it (miraculously) did, what...

Help understanding boost::bind placeholder arguments

I was reading a StackOverFlow post regarding sorting a vector of pairs by the second element of the pair. The most obvious answer was to create a predicate, but one answer that used boost caught my eye. std::sort(a.begin(), a.end(), boost::bind(&std::pair<int, int>::second, _1) < boost::bind(&std::pair<int, int>::second, _2)); I'...

What all Design Patterns can I use ?

1. I need to build a "Web Service Server (Simulator)" which generates the xml files and also sends async calls to the client for notification. At this point, I am writing a code to generate dummy XML files which will be used for testing (FileGeneratorClass-- builder)? 2. Also, can I implement this in a way that I do not have to write a...

Looking for a metafunction from bool to bool_type

Basically, I am looking for a library solution that does this: #include <boost/type_traits.hpp> template<bool> struct bool_to_bool_type; template<> struct bool_to_bool_type<false> { typedef boost::false_type type; }; template<> struct bool_to_bool_type<true> { typedef boost::true_type type; }; Is there such a metafunction? ...

Possible reasons for tellg() failing?

ifstream::tellg() is returning -13 for a certain file. Basically, I wrote a utility that analyzes some source code; I open all files alphabetically, I start with "Apple.cpp" and it works perfectly.. But when it gets to "Conversion.cpp", always on the same file, after reading one line successfully tellg() returns -13. The code in questi...

i violated D.R.Y. help me please?

I'm making a blackjack sim and I want to deal the cards how it would be in a casino, i.e. all players get dealt a card, dealer gets one face down, players get another card, dealer gets one face up BUT LOOK I VIOLATED DRY :( How to redo?? void BlackJack::newHand() { resetHands(); for (unsigned int i = 0; i < players.size(); i...

const pointers in overload resolution

GCC treats these two function declarations as equivalent: void F(int* a) { } void F(int* const a) { } test.cpp: In function 'void F(int*)': test.cpp:235: error: redefinition of 'void F(int*)' test.cpp:234: error: 'void F(int*)' previously defined here This makes some sense because a caller will always ignore the const i...

Any RAII template in boost or C++0x

Is there any template available in boost for RAII. There are classes like scoped_ptr, shared_ptr which basically work on pointer. Can those classes be used for any other resources other than pointers. Is there any template which works with a general resources. Take for example some resource which is acquired in the beginning of a scope ...

Can Someone Explain Threads to Me?

I have been considering adding threaded procedures to my application to speed up execution, but the problem is that I honestly have no idea how to use threads, or what is considered "thread safe". For example, how does a game engine utilize threads in its rendering processes, or in what contexts would threads only be considered nothing b...

Why does the interface for auto_ptr specify two copy-constructor-like constructors

I was going through the auto_ptr documentation on this link auto_ptr There is something which i could not fully understand why is it done. In the interface section there are two declarations for its copy constructor 1) auto_ptr(auto_ptr<X>&) throw (); 2) template <class Y> auto_ptr(auto_ptr<Y>&) throw(); What purpose i...

Visual Studio 2008 C++ dependencies

Hi, i'm developing a C++ simulation (OpenGL) on top of VS2008 enviroment. My current operating system is Windows Vista. The trouble is that when trying to execute the application on a Windows XP machine, my application crashes because incompatibilities beteween DLL's (namely, msvcrt.dll function entry points ) ... Has anyone experienced...