c++

Playing AVI files in OpenCV

Hi all, I can't seem to play my avi files using OpenCV. I am on a Mac and the files work with Quicktime and VLC player. I have tried using mencoder to convert it to i420 but that still has not been successful. No error messages occur and it seems like the program closes automatically and I'm not sure how to debug it. int main(int arg...

Light weight container around const char* & length without copying the data

I have a underlying API that passes a const char* and a length: foo(const char* data, const uint32_t len); I'd like to wrap this data/length in a light weight container that can be iterated and has the ability to be randomly accessed but not make a copy (e.g. like a vector). What is the best way to achieve this? The const char* data i...

Calling member functions from DLL (AI library for games)

My problem is this: I am trying to implement a C++ library which can call functions in the base EXE. I am trying to have a minimum amount of code on the EXE side to get the functionality to work. At the moment I have DLL-side entities which are created by DLL function calls. These entities hold a container of "actions" which is just a ...

c++ return reference / stack memory

A basic question that I'm not sure of the answer. Is the follow function valid? std::vector<int> & test_function() { std::vector<int> x; // do whatever return x; } If so, why? Shouldn't the program delete x from the stack after the function returns? Thanks. ...

Trouble with 'extern' Keyword

Hi, I have a set of global variables and a method in a cpp file. int a; int b; int c; void DoStuff() { } in the header file I have declared them explicitly with the extern keyword. My problem is when I include the header file in another C++ file, I can't use the external variables and the method. It's giving a linker error sayin...

Porting C++ code to Silverlight

I have C++ application which has UI developed using MFC, does some networking using sockets (using boost libraries) and some image processing. I want to move this application into Silvelight framework (I can use 4.0 if required) so that it can be used over the internet easily. Here I want to move all parts (UI + networking etc) in to C# ...

Is C++ name mangling (decoration) deterministic?

I hope to LoadLibrary on an unmanaged C++ DLL with managed code, and then call GetProcAddress on extern functions which have been mangled. My question is are the mangled names you get from a C++ compiler deterministic? That is: Will the name always by converted to the same mangled name, if the original's signature hasn't changed? ...

Implementing the clrscr() funtion to understand its working

I am trying to make the copies of the builtin functions and adding a x to their name so i can understand each functions working.While writing a function for clrscr() i am confused about how it works.Does it use 2 nested loops and print (" ") i.e space all over the screen or it prints("\n") over the screen?Or what? I tried this: #include...

what is the difference between Malloc and new operator to allocate a memory?

Possible Duplicate: What is the difference between new/delete and malloc/free? I was confused when I create an object by using new operator in C++. There must be difference between malloc and new operator that would allow me to resize the memory block. If I want to allocate a memory I use malloc but what if I use a new operato...

How to rotate monochrome images in GDI+

I am trying to rotate a monochrome Bitmap in GDI+ using RotateFlip method. When i try to rotate it by 90/270 I get a wrong image or the application crashes. But when I try to rotate it by 180 degrees it works fine. Hence I am now rotating all monochrome bitmaps twice through 180 and then rotating it again by the angle required. Is this ...

C++ container class type conversion

Say, i got Set<DerivedClass*> set1; and i got Set<BaseClass*> set2; how do i do this? Set<BaseClass*> set3 = set1.substract(set2); //static cast! ...

What is good way to maintain versions in a C++ project?

We have a C++ project, which has hundreds of SVN revisions every month. Sometimes we need to increment a minor digit in a version number, changing it from, say, 1.6 to 1.7. We do it once per month approximately. What is a correct approach to do it? We want to save/maintain information about changes made in every new version, and we want ...

How do you enable auto-complete functionality in Visual Studio C++ express edition?

Please guide me, how do you enable autocomplete functionality in VS C++? By auto-complete, I mean, when I put a dot after control name, the editor should display a dropdown menu to select from. Thank you. ...

code from hackers delight

/* Converts the unsigned integer k to binary character form with a blank after every fourth digit. Result is in string s of length 39. Caution: If you want to save the string, you must move it. This is intended for use with printf, and you can have only one reference to this in each printf statement. */ char * binary(unsigned k) { ...

What is the meaning of this code

I found following code in one of the frameworks we are using, if (nValue + 0.01 > nLimit) nValue = nValue - 0.01; if (((nValue+1) / (int)(nValue+1)) == 1) sprintf(szValue, "%0.0f", nValue); else sprintf(szValue, "%0.2f", nValue); what is the meaning of this code ...

What's the clue to make stringstream write binary?

What I'm trying to do is, make the class message serialize and deserialize it's self. Not into or from a file, but into or from a binary sequence as a string or cstring. Message.h: class Message { private: int message_id; int sender_id; std::string sender_data; Message (); public: Message (int id, std::string da...

BDM elf file vs normal elf file

Whats the advantage that the BDM ELF file has over the nomral ELF file in terms of memory used? I know the following things about both: 1) BDM ELF file could be used for debugging through any debugger tools like Trace32 by plugging in JTAG. The normal ELF file also can be used for debugging purpose, provided we have the corresponding F...

Strange words appearing during compilation of Application

I am having a service written in C++ and i use VC++ 6.0. When i build this service i get a strange message as shown (The letter 'T'coming during compilation). Though it does not cause any problem, i would like to know why this message occurs. Compiling... SerString.cpp SerSwitcher.cpp Smtp.cpp SysConfigBlob.cpp T T TransLateReportNames...

C++ Undefined Type Error

Dear all, i have two classes which are computer and floppy disk. When i put #include "FloppyDisk.h" #include "Computer.h" in main, then compiler generates error of computer undeclared When i #include "Computer.h" #include "FloppyDisk.h" in main, then compiler generates error of floppy disk undeclared. What is the problem? I...

Possibly a Pointer Problem in C

Hi all, I am not sure why the following code fragement is not doing what it is supposed to do. Returning the numbers 0 to 9 in the second loop would be idea. *scp is a pointer to a memory region allocated to the program. unsigned char* scp = (unsigned char*)(0x8e000000); scp_size = 10; for(i = 0; i < scp_size; i++, scp++) { *scp ...