c++

How to control flash movie using activex wrapper ?

How to play the flash movie always from the beginning ? Any way to rewind movie ? I have use rewind() method for that but it didn't work. Any help is welcomed.... ...

Trying to create a .NET DLL to be used with Non-.NET Application

I am trying to create a .NET DLL so I can use the cryptographic functions with my non .NET application. I have created a class library so far with this code: namespace AESEncryption { public class EncryptDecrypt { private static readonly byte[] optionalEntropy = { 0x21, 0x05, 0x07, 0x08, 0x27, 0x02, 0x23, 0x36, 0x45, 0x...

template specialization of a auto_ptr<T>

Maybe I'm overcomplicating things, but then again, I do sort of like clean interfaces. Let's say I want a specialization of auto_ptr for an fstream - I want a default fstream for the generic case, but allow a replacement pointer? template <> class auto_ptr<fstream> { static fstream myfStream; fstream* ptr; public: ...

Help with C++ Boost::regex

Hello everybody, I'm trying to get all words inside a string using Boost::regex in C++. Here's my input : "Hello there | network - bla bla hoho" using this code : regex rgx("[a-z]+",boost::regex::perl|boost::regex::icase); regex_search(input, result, rgx); for(unsigned int j=0; j<result.size(); ++j) ...

Building external code trees with SCons

Hello, I'm trying to use SCons for building a piece of software that depends on a library that is available in sources that are installed in system. For example in /usr/share/somewhere/src. *.cpp in that directory should be built into static library and linked with my own code. Library sources have no SConscript among them. Since libra...

Compiler error when overriding virtual methods

Using VC71 compiler and get compiler errors, that i don't understand. Here comes the example class A { public: virtual int& myMethod() = 0; virtual const int& myMethod()const = 0; }; class B: public A { public: // generates: error C3241: 'const int &B::myMethod(void)' : this method was not introduced by 'A' virtual int& A::myM...

Tool for finding C-style Casts

Does anyone know of a tool that I can use to find explicit C-style casts in code? I am refactoring some C++ code and want to replace C-style casts where ever possible. An example C-style cast would be: Foo foo = (Foo) bar; In contrast examples of C++ style casts would be: Foo foo = static_cast<Foo>(bar); Foo foo = reinterpret_cast<...

Can I specify default value?

Why is it that for user defined types when creating an array of objects every element of this array is initialized with the default constructor, but when I create an array of a built-in type that isn't the case? And second question: Is it possible to specify default value to be used while initializing elements in the array? Something li...

Smart pointers - cases where they cannot replace raw pointers

HI, I have this query about smart pointers. I heard from one of my friends that smart pointers can almost always replace raw pointers. but when i asked him what are the other cases where smart pointers cannot replace the raw pointers,i did not get the answer from him. could anybody please tell me when and where they cannot replace ra...

How to use C++ Boost's regex_iterator()

Hello, I'm using boost library to match substrings in a text. to iterate over results i need to use regex_iterator (see http://www.boost.org/doc/libs/1_42_0/libs/regex/doc/html/boost_regex/ref/regex_iterator.html) that's the only usage example i have found, but it's not clear for me (i don't understand the callback). could someone fa...

C++-Singleton class

Can a singleton class be inherited. if yes, then how can we do it? EDIT:I mean to say that if we have a class which uses singleton design pattern,then can it be inherited? ...

Do classes which have a vector has a member have memory issues

I am just starting out C++, so sorry if this is a dumb question. I have a class Braid whose members are vectors. I have not written an assignment operator. When I do a lot of assignments to an object of the type Braid, I run into memory issues :- 0 0xb7daff89 in _int_malloc () from /lib/libc.so.6 #1 0xb7db2583 in malloc () from /lib/...

Calling unmanaged c++ code in C# Mixed with STL

Hey, I want to call unmanaged c++ code in C# The function interface is like following(I simplified it to make it easy to understand) Face genMesh(int param1, int param2); Face is a struct defined as: struct Face{ vector<float> nodes; vector<int> indexs; } I googled and read the MSDN docs found ways to call simple c/c++ un...

Segfault when calling a method c++

I am fairly new to c++ and I am a bit stumped by this problem. I am trying to assign a variable from a call to a method in another class but it always segfaults. My code compiles with no warnings and I have checked that all variables are correct in gdb but the function call itself seems to cause a segfault. The code I am using is roughly...

How to set configuration properties in VS once and for all?

In VS 2010RC I have to specify configuration properties and specifically included path every time I'm creating new project. Is there a way to do it just once for all future projects? I'm asking this for a reason that I'm starting to use Boost libraries and I have to specify all those paths every time I'm creating project which is bit ted...

Using deprecated binders and C++0x lambdas

C++0x has deprecated the use of old binders such as bind1st and bind2nd in favor of generic std::bind. C++0x lambdas bind nicely with std::bind but they don't bind with classic bind1st and bind2nd because by default lambdas don't have nested typedefs such as argument_type, first_argument_type, second_argument_type, and result_type. So I...

error: 'void Base::output()' is protected within this context

I'm confused about the errors generated by the following code. In Derived::doStuff, I can access Base::output directly by calling it. Why can't I create a pointer to output() in the same context that I can call output()? (I thought protected / private governed whether you could use a name in a specific context, but apparently that is i...

invalid conversion from ‘char*’ to ‘char’

Hi Guys, I have a, int main (int argc, char *argv[]) and one of the arguements im passing in is a char. It gives the error message in the title when i go to compile How would i go about fixing this? Regards Paul ...

Why do you need "extern C" for C++ callbacks to C functions?

Hello, I find such examples in Boost code. namespace boost { namespace { extern "C" void *thread_proxy(void *f) { .... } } // anonymous void thread::thread_start(...) { ... pthread_create(something,0,&thread_proxy,something_else); ... } } // boost Why do you actually need thi...

c++ stl priority queue insert bad_alloc exception

Hi, I am working on a query processor that reads in long lists of document id's from memory and looks for matching id's. When it finds one, it creates a DOC struct containing the docid (an int) and the document's rank (a double) and pushes it on to a priority queue. My problem is that when the word(s) searched for has a long list, when ...