c++

Question regarding pragma Ident

Hi Guys Can you please explain what is the meaning of each key in the following declaration #pragma ident "%Z% %M% v%I% (c) GEMS %G%" I am using Clearcase Revision Control System ...

String array and Arraylist/list in C++

Hi, I am new to C++, can anybody provide me some sample program's for String array and Arraylist/list in C++ Thanks in Advance. ...

is there any image library can cut the white edge of a picture?

Hi All, I'd like to know if there are any image librarys can cut the white edge of a picture automatically, for example: cut The Wonderful Wizard of Oz.png to cutted.png opensource would be very handy Thanks advance for your help. Best regards, hb ...

type-safety by using the ellipsis notation

Hi all, it had been several times discussed in other subjects that it is not recommended to use variadic function because the compiler can't check the type of provided arguments. But what about if the user knows exactly the type can be e.g. std::string. Could anything still go wrong here too? regards ...

Learning C++ or Java for future lower level programming?

I know Ruby and PHP and want to start learning a lower level programming. I'm having a hard time choosing between C++ and Java, and coming from only dynamic languages I don't know exactly what I can do with C++ and not Java, and vice versa. Could someone explain what the benefits (focused on features) are for each of them? ...

Efficient structure for Multiple Thread access

I need to implement a mechanism which has a datastruture (Queue at this moment) that contains a list of pending request objects which are marked by different threads when being used and taken off when a thread is finished using it. This datastructure could have up to a few thousand items in it at any given time and N threads will be t...

How are vtables implemented in c++ and c#?

Lets have this situation (in c++, in c# classes A,B are interfaces): class A { virtual void func() = 0; }; class B { virtual void func() = 0; }; class X: public A, public B { virtual void func(){ var = 1; } int var;}; X * x = new X; // from what I know, x have 2 vtables, is this the same in c#? A * a = (A*)x; // a == x B * b = (B*)x; /...

c++ - printf on strings prints gibberish

Hi, Sorry about the simple question - I'm a newby (obviously): I'm trying to print a string the following way: int main(){ string s("bla"); printf("%s \n", s); ....... }; but all I get is this random gibberish. Can you please explain why? Thanks, Li ...

Android NDK Confusion

Hey, I've been playing around with the NDK recently, finding that many of the tutorials available online really don't help. I've been using this tutorial and I've got it running great. However. Is this the correct use of the NDK? I mean if I have a game say with many classes all in C++ that I wish to port over to the android. Do I have...

How to test if a constant fits into a type while compiling?

I'd like to add compile time asserts into the following C++ code (compiled with Visual C++ 9): //assumes typedef unsigned char BYTE; int value = ...; // Does it fit into BYTE? if( 0 <= value && value <= UCHAR_MAX ) { BYTE asByte = static_cast<BYTE>( value ); //proceed with byte } else { //proceed with greater values } The ...

what is data abstraction exactly means

Hi all, what is data abstraction means? can i get some sample examples as well as real time examples in our daily life ...

"filter" higher order function in C++

Does C++ standard library and/or Boost have anything similar to the filter function found in functional languages? The closest function I could find was std::remove_copy_if but it seems to be doing the opposite of what I want. Does boost::lambda have any function to get a negated version of my predicate (similar to not in Haskell)? I co...

parse an unknown size string

I am trying to read an unknown size string from a text file and I used this code : ifstream inp_file; char line[1000] ; inp_file.getline(line, 1000); but I don't like it because it has a limit (even I know it's very hard to exceed this limit)but I want to implement a better code which reallocates according to the size of the coming s...

boost::threads execution ordering

hello i have a problem with the order of execution of the threads created consecutively. here is the code. #include <iostream> #include <Windows.h> #include <boost/thread.hpp> using namespace std; boost::mutex mutexA; boost::mutex mutexB; boost::mutex mutexC; boost::mutex mutexD; void SomeWork(char letter, int index) { boost:...

Ambiguous Syntax

#include <iostream> using namespace std; typedef int MYINT; int main() { int y = MYINT(); // As expected, y = 0; value initialization cout << MYINT(); // Error cout << sizeof(MYINT()); // Error } Why the last two lines in the main function before the closing brace giv...

Declaring an instance of an explicit specializtion of a template within a regular class

I can't get this to compile at all. I may not be possible but I don't know why it should not be. class A { template <typename T> class B { int test() { return 0; } }; //template <> class B<int>; <-with this, namepace error B<int> myB_; }; template <> class A::B<int> { int test() { return 1; } }; As it appears ...

[C++] Uniquely identify PC based on software/hardware

For a requirement to generate per-PC license keys, I need some code which will return a stable and (near) unique key on any PC. It doesn't have to be guaranteed unique, but close. It does need to be reasonably stable though, so that a given PC always generates the same result unless the hardware is substantially changed. This is for a W...

Asynchronous COM C++ calls

Following up from part of this question, what is the best way to have a worker thread that invokes a COM procedure in a DLL, to do this asynchronously so that the worker thread is not blocked on this call? Note that a call to this COM DLL can take a long time as it will do DB accesses and possible run long running queries. I wondered i...

Install DLL Server on x64 Windows

I need to install a shell extension (64-bit DLL server) for the contextual menu on any version of Windows x64. I'm able to register the extension just fine (regsvr32) if on the target system I have installed the redistributable files for VS 9.0 SP1 x64 (setup file from Microsoft). However I have to make a setup and cannot require the us...

Cross platform sound API for games?

Is there an API only for sound? API's such as Allegro or SDL provide too much for my needs. I simply need a library that can do something like: InitSound(); Sound *door = LoadSound("door.wav"); PlaySound(door,volume); It would also be great if it could support compressed formats such as vorbis or mp3. Thanks ...