c++

C++ Mystery

Can someone explain to me why this code prints 14? I was just asked by another student and couldn't figure it out. int i = 5; i = ++i + ++i; cout<<i; ...

Web service can't open named pipe - access denied

Hi All, I've got a C++ service which provides a named pipe to clients with a NULL SECURITY_ATTRIBUTES as follows: hPipe = CreateNamedPipe( lpszPipename, PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED, PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT, PIPE_UNLIMITED_INSTANCES, BUFSIZE, BUFS...

How do C/C++ compilers handle type casting?

I am curious to know how Type Casting happens without loss of data inside the compiler. For example: int i = 10; UINT k = (UINT) k; float fl = 10.123; UINT ufl = (UINT) fl; // data loss here? char *p = "Stackoverflow Rocks"; unsigned char *up = (unsigned char *) p; How does the compiler handle this type of typecasting. A lo...

Missing 'virtual' qualifier in function declarations

Whilst trawling through some old code I came across something similar to the following: class Base { public: virtual int Func(); ... }; class Derived : public Base { public: int Func(); // Missing 'virtual' qualifier ... }; The code compiles fine (MS VS2008) with no warnings (level 4) and it works as expected - Func i...

Tool to browse Multi-thread (C++/C) code ?

We are using multi-thread in our fairly large product, but when doing review we hardly know a function or method will run under which thread. I know this looks stupid, but in a large product without good modularization, we can lost. And there are many potential synchronization problems are aware of. So I'm wondering if there are tools f...

Unable to load C++ DLL in C# application in Vista x64

I have a DLL written in C++ that needs to be used by an application in C#. It works great under Vista x86, but under x64 it fails to load. So I build an x64 version of the DLL and I detect whether the OS is x86 or x64 and use the appropriate interop call to the appropriate DLL. This works fine under Vista x86, but under Vista x64 I get a...

Which transpilers are out there?

While examining aspell to figure out how to write my own spell checker in Java, I wondered how much work it would be to convert aspell to some dialect of C which is close enough to Java that it's possible to compile both a C and a Java version from the same source. Of course, there is UML which promises that you can "model" your problem...

C++ Multi-dimensional Arrays on the Heap

I went looking for this the other day, and thought it should probably be added to StackOverflow's reservoir of questions. How would I go about dynamically allocating a multi-dimensional array? ...

outlook display icon in notification area for messages not in inbox

I have rules set to move some email messages into different folders. I would like this to still show the envelope in the notification area but there is no option in the rules wizard to do this. It looks like I would either have to have the rule "run a script" or "perform a custom action" allowing either vba or c/c++ respectively. Anyone...

Hide Comments in Code in Unix Environment

I work in a Unix environment with the typical Unix tools (emacs, vim, gvim, sunstudio, etc) My project has huge gross boilerplate comments on every method. It makes the files thousands of lines long, with a couple hundred lines of actual code. I may be exagerrating a bit but you get the idea. I am looking for a way when viewing these fi...

Segmentation fault using SDL with C++, trying to Blit images

OK - I have an interesting one here. I'm working on a tetris clone (basically to "level-up" my skills). I was trying to refactor my code to get it abstracted the way I wanted it. While it was working just fine before, now I get a segmentation fault before any images can be blitted. I've tried debugging it to no avail. I have posted ...

Viewing language (C/C++) reference/documentation in CodeBlocks

Hi there! My first question on StackOverflow... Does anybody know a way of viewing the reference/documentation manual of a language through CodeBlocks? Specifically for C/C++. Example: Say I want to look up the reference for strncpy(). In a very old Borland system (which we use at school) I would write the word and middle-click on it,...

Using only std::exception in exception specification

It seems it is general accepted that exception specifications are not helping as much as one thinks. But I wonder if a specification which only uses std::exception might be a good compromise: void someFunction() throw ( std::exception ); It documents the fact that this method/function might throw an exception. It would make sure ...

What's the difference between BSTR and _bstr_t ?

Anyone can explain the difference between types mentioned above and some sample usage to clearly explain the difference between the two? Any help would be highly appreciated! Note: this question is a spin-off from this other question ...

How to use libapt (or libept) in debian-like system to list packages and get their infos?

Somebody used libapt or libept to list packages and get informations about package in a debian-like system? Libapt is not well-documented at all, and i've found few examples and tutorials about libept. Can someone explain me best methods to get a list of every packages in the apt-system get informations about single packages (like na...

Is it possible to build a DLL in C++ that has no dependencies?

I would like to deploy a very simple DLL with my C# application, but any DLL that I build in Visual Studio 2008 seems to have a dependency on "Microsoft.VC90.CRT". Is it possible to build a DLL using VS2008 without this dependency? How can I tell what is causing the dependency? ...

On Windows, when should you use the "\\\\?\\" filename prefix?

I came across a c library for opening files given a Unicode filename. Before opening the file, it first converts the filename to a path by prepending "\\?\". Is there any reason to do this other than to increase the maximum number of characters allowed in the path, per this msdn article? It looks like these "\\?\" paths require the Uni...

How do I read system information in C++?

I'm trying to get information like OS version, hard disk space, disk space available, and installed RAM on a Linux system in C++. I know I can use system() to run different Linux commands and capture their output (which is what I'm currently doing) but I was wondering if there's a better way? Is there something in the C++ standard libr...

How to convert from HBITMAP to .NET's Bitmap class?

I am using some C++ code that employs the CreateDIBSection function to create a bitmap and return a HBITMAP handle. What is the best way of getting this information into my .NET assembly? ...

C++: invalid conversion from ‘BaseNode*’ to ‘Match*’

All objects in my program inherit from a Container class. The Container class has a virtual BaseNode* getParent() const; method and a virtual void setParent(BaseNode *p); method. I have a Set class (Set in a tennis match, not a data structure) which has the Match class as it's parent (via setParent()) but since Set inherits from Contai...