I was checking the behavior of dynamic_cast and found that when it fails, std::bad_cast exception is thrown only if the destination is a reference type. If the destination is a pointer type then no exception is thrown from the cast. This is my sample code:
class A
{
public:
virtual ~A()
{
}
};
class B : public A
{
};...
Hi,
I'm building an application where I need to use a saveFileDialog. The problem is that I want to restrict the users from using some parts of the saveFileDialog (e.g. I don't want them to edit the name of the file). I've heard that it's very difficult to do this using Windows forms SaveAsDialog. Do you know how to do this in native c...
I have a message coming from an external company which has been encrypted with our public key using Java.
Specifically the java code performing the encryption is -
//get instance of cipher using BouncyCastle cryptography provider
Cipher cipher = Cipher.getInstance( "RSA/ECB/PKCS1Padding", "BC");
//initialize the cipher with th...
When building a C++ application in Visual Studio 2008, I receive the following error: iconfile.ico is not in 3.00 format.
I created the icon file using Paint, and saved it as a .ico file.
I tried saving it as 16 bit, 24 bit, and 256 color.
So far, none of these formats appear to be version 3.00.
How do I resolve this?
...
Hi
The following code fragment ends in an exception when executing the strncpy funtion:
#define MAX_FILENAME_LEN 127
typedef struct {
unsigned long nameLength;
char name[MAX_FILENAME_LEN + 1];
} filestructure;
char *fileName;
strncpy( fileName, filestructure->name, MAX_FILENAME_LEN );
*( fileName + MAX_FILENAME_LEN+1 ) = 0;
Ayone ...
Hi,
My Home directory is shared among several linux computers via Network File System.
I would like to install some C C++ library from source under my Home directory, and wish they can be used under all the linux computers.
Do I have to install different versions of the library under different directories of my Home for different compu...
I have a CListCtrl derived class that provides subitem editing by creating a CEdit starting at the correct offset of the subitem. Sometimes the subitem is only partially visible so I scroll the CListCtrl to the offset location to gain more space for the CEdit.
Now something very weird happens: On Windows Vista and Windows 7 the CListCtr...
I'm trying to make a C++ API (for Linux and Solaris) thread-safe, so that its functions can be called from different threads without breaking internal data structures. In my current approach I'm using pthread mutexes to protect all accesses to member variables. This means that a simple getter function now locks and unlocks a mutex, and I...
We know that C++ doesn't allow templated virtual function in a class. Anyone understands why such restriction?
...
Hi,
Here are my two questions:
I am now learning to manage my code with CVS, and I just want to make a repository for my C++ files, Makefile and bash and python scripts only, not the object files and executables. So I made several subdirectories under my project directory: src, bin, scripts, results and data. I put C++ files and Makefi...
If the same code is built at different times w/gcc, the resulting binary will have different contents. OK, I'm not wild about that, but that's what it is.
However, I've recently run into a situation where the same code, built with the same version of gcc, is generating a binary with a different size than a prior build (by about 1900 by...
I'm creating 3 events with the following function:
HANDLE WINAPI CreateEvent(...);
I'm waiting on all (bWaitAll is set to TRUE) event objects or a timeout with:
DWORD WINAPI WaitForMultipleObjects(...);
The return value is:
WAIT_TIMEOUT
Is there an easy way to check each event to find the one(s) that was(where) not set?
As an e...
What is the difference between Boost::bind and Boost Phoenix::bind?
...
I've always read and been told that when dealing with binary files that one should use read() and write() as opposed to the << and >> operators as they are meant for use with formatted data. I've also read that it is possible to use them, but it is an advanced topic, which I can't find where anyone dives into and discusses.
I recently ...
I read the tutorials and so, but I am not getting it. It does let you send packets, but how can you tell Winpcap where to send those packets? Is there any header I should put on the packets so it will know to which ip/port's to forward it? I mean. Let's imagine I want to send some data to my MSN, as if I had wrote something to someone on...
I'm trying to use Boost::bind and std::copy to print out the values in a list of lists. Obviously, I could use loops, and I may end up doing so for clarity, but I'd still like to know what I'm doing wrong here.
Here is the distilled version of my code:
#include <boost/bind.hpp>
#include <iterator>
#include <algorithm>
#include <list>
...
I have an interesting stack of assemblies I want to put together:
Common Assembly (C# or C++)
public class MyBase
{
public void MethodA()
{ ... }
private void MethodB()
{ ... }
protected virtual MethodC()
{ ... }
}
Test Code Assemblies (all C++)
public class MySpecific : public MyBase{
protected: override MethodC();
};
Test Simulat...
I'm using phoenix::bind and receiving this error message:
error C2039: 'bind' : is not a member
of 'phoenix'
The code line where I'm using bind and where the error is pointing is:
phoenix::bind(
&OptionalInputPort::eraseDataEditor )
( phoenix::var( *optionalPort ) )
and I can't figure out what is the pro...
If I run:
FILE* pFile = fopen("c:\\08.bin", "r");
fpos_t pos;
char buf[5000];
int ret = fread(&buf, 1, 9, pFile);
fgetpos(pFile, &pos);
I get ret = 9 and pos = 9.
However if I run
FILE* pFile = fopen("c:\\08.bin", "r");
fpos_t pos;
char buf[5000];
int ret = fread(&buf, 1, 10, pFile);
fgetpos(pFile, &pos);
ret = 10 as expected, ...
Or do I have to implement it at the application level?
...