Last question for tonight, I promise. These pointers are giving me a serious headache.
I have a std::list<Point> called Polygon and a std::list of Polygons defined like:
typedef std::list<Point> Polygon;
typedef std::list<Polygon> PolygonList;
// List of all our polygons
PolygonList polygonList;
I created the method below to att...
I want to read sizeof(int) bytes from a char* array.
a)In what scenario's we need to worry if endian needs to be checked
b)how would you read the first 4 bytes considering taking endian consideration or no consideration.
EDIT: The sizeof(int) bytes that I have read needs to be compared with the an integer value.
What is the best app...
I have a small piece of code that works as a plugin for a larger graphics application. The development platform is Qt with c++ code. I've managed to build a .so, .dylib and .dll for linux, MacOS and Windows respectively, but to do so I had to have a machine running each operating system (in my case, running linux [ubuntu] gcc natively,...
I tried to make my program dump and save its stack trace when crashes. I installed my own win32 SE handler with _set_se_translator and tried to dump the stack trace with StackWalk64 and finally throw a C++ exception (which actually does the logging when caught).
The code looks like this:
...
_set_se_handlers(WIN32EXCEPTION::Win32Except...
Is there any way that you can combine predicates?
Lets say I have something like this:
class MatchBeginning : public binary_function<CStdString, CStdString, bool>
{ public:
bool operator()(const CStdString &inputOne, const CStdString &inputTwo) const
{ return inputOne.substr(0, inputTwo.length()).compare(inputTwo) == 0; }
};...
Hi,
Does anyone know how to set font and color on a static text and other controls of MFC dialog for Windows Mobile?
Where can I get the list of supported fonts?
Thanks!
...
I'd like to initialize a map - object "id" with identities from 0 to n-1, i.e.
id[0] = 0
id[1] = 1
.
.
id[n-1] = n-1
Is there a simple way - a one-liner, a method inside the map-object, simply something really simple - that does that?
...
I am working with Informix in C++ with the IBM CSDK client libraries. I use the multi-threaded version of the libraries and each thread uses its own ITConnection object.
Still the application crashes if more than one thread is spawned.
Has anybody come across a similar problem?
...
My brother recently started learning C++. He told me a problem he encountered while trying to validate input in a simple program. He had a text menu where the user entered an integer choice, if they entered an invalid choice, they would be asked to enter it again (do while loop). However, if the user entered a string instead of an int, t...
Hello! ... and thanks for reading...
I'm still learning the ropes so please be forgiving... ;-)
I am writing a function that meshes a solid in space. The mesh is done by using objects of a "Node" class and each node is represented by:
int id
double p
double r
Initially I thought that a map would be the way to go: with a map I can m...
I'm currently in the process of learning C++, and because I'm still learning, I keep making mistakes.
With a language as permissive as C++, it often takes a long time to figure out exactly what's wrong -- because the compiler lets me get away with a lot. I realize that this flexibility is one of C++'s major strengths, but it makes it dif...
What would be the best way to pass information from a windows forms C# app to a MFC C++ app while they are running? I don't need to send much, just a small string.
Thanks,
Jeff
...
Are there any language lawyers in the house?
Should the following code compile?
include <set>
bool fn( const std::set<int>& rSet )
{
if ( rSet.find( 42 ) != rSet.end() ) return true;
return false;
}
On one of the platforms (Sun Workshop) this does not compile. It reports that the find function returned an iterator and the end fu...
Is it possible to do something like this
#ifdef SOMETHING
#define foo //
#else
#define foo MyFunction
#endif
The idea is that if SOMETHING is defined, then calls to foo(...) become comments (or something that doesn't get evaluated or compiled), otherwise it becomes a call to MyFunction.
I've seen __noop used, but I don't believe I ca...
As per this website, I wish to represent a Maze with a 2 dimensional array of 16 bit integers.
Each 16 bit integer needs to hold the following information:
Here's one way to do it (this is by no means the only way): a 12x16 maze grid can be represented as an array m[16][12] of 16-bit integers. Each array element would contains all t...
I am trying to implement a function called "inet_pton" which will convert a string representation of an IPv4 or IPv6 (like "66.102.1.147" [google]) into binary network-byte ordered form. Here is the relevant part of my code:
#if defined WIN32
int inet_pton (int af, const char *src, void *dst)
{
const void *data;
size_t le...
Consider these types:
struct A {};
struct B : A { int i; };
sizeof(A) > 0 as required by the standard.
sizeof(B) should be 4 due to the empty base optimization. Yet on GCC 4.1.1 it's 5 (I'm using a pack of 1 in this area). And inconsistently - some of my files are getting it, some are not. Can't be sure what the differences are y...
In my job, i need to parse different kind of data files from different data sources.Sometimes i parse them by writing directly c++ code (with the help of qt and boost:D), sometimes manually with a helper program.
I must note that data types are so different from each other it is so hard to create common a interface for all of them. But i...
I'm creating my first real binary parser (a tiff reader) and have a question regarding how to allocate memory. I want to create a struct within my TiffSpec class for the IFD entries. These entries will always be 12 bytes, but depending upon the type specified in that particular entry, the values at the end could be of different types (or...
I have an interesting problem. Consider this class hierachy:
class Base
{
public:
virtual float GetMember( void ) const =0;
virtual void SetMember( float p ) =0;
};
class ConcreteFoo : public Base
{
public:
ConcreteFoo( "foo specific stuff here" );
virtual float GetMember( void ) const;
virtual void SetMember( float p ...