Possible Duplicate:
Best way to detect integer overflow in C/C++
i have tried to implement simple program which tests if overflow occurs during integer addition:
#include <climits>
#include <iostream>
#include <string>
using namespace std;
string overflow(long a,long b){
return ((a+b)>UINT_MAX)?"true":"false";
}
int ma...
Hi guys,
I need to call properties and functions of an object from a different class.
The idea is passing 'this' as a parameter to the other class constructor. E.g.:
instance = ClassName(this);
And then do:
ParentClass parentInstance;
ClassName::ClassName(MainApp _instance){
parentInstance = _instance;
}
However, my compiler ...
Hello every one!
Has any one managed to use libxml2 with axis2c. Please correct me if i am wrong , if one goes with libxml2, all parsing/creation will be done by libxml2 api and not axiom api.. I would love to see a simple example for managing requests & response.I had a look at the wrapper classes , unfortunately i can not make how to...
I am just beginning to learn how to program DirectX 9 applications in C++, so I'm still not very good, and I'm messing it around quite a bit.
When I reopen the program after it crashes, the D3D Device fails to create with the result being D3DERR_INVALIDCALL. I am compiling with G++ in MinGW, using the DirectX August 2009 SDK. I'm guessi...
I understand, using srand(time(0)), helps in setting the random seed. However, the following code, stores the same set of numbers for two different lists.
Wondering, how do I generate the different set of numbers when the following function gets called more than once.
void storeRandomNos(std::list<int>& dataToStore)
{
int noofElem...
i am using visual c++ 2010 i want to learn create processes in c++ can anybody help where find tutorial or does here exist book?
thanks
...
boost signals allows temporarily blocking a connection via a connection member function. However, I have a single signal with many connections. The connections are stored and maintained by their respective listeners. Now the broadcaster decides that it wants to stop sending signals for a while. There does not seem to be a way to iterate ...
Trying to write a GLOBAL CBT HOOK,
this is My code, but my hooking app doesn't recieve any Messages, neither writes the dll something to a test file.
This is My Code:
#include "stdafx.h"
#include "GlobalHook.h"
#include "Stdafx.h"
#include <iostream>
#include <fstream>
#define DLL_EXPORT
#include "GlobalHook.h"
#include <windows....
I'm trying to translate a huge project from C++ to Delphi and I'm finalizing the translation. One of the things I left is the '\0' monster.
if (*asmcmd=='\0' || *asmcmd==';')
where asmcmd is char*.
I know that \0 marks the end of array type in C++, but I need to know it as a byte. Is it 0?
In other words, would the code below be the...
Right now I'm using this to set/unset individual bits in a byte:
if (bit4Set)
nbyte |= (1 << 4);
else
nbyte &= ~(1 << 4);
But, can't you do that in a more simple/elegant way? Like setting or unsetting the bit in a single operation?
Note: I understand I can just write a function to do that, I'm just wondering if I won't be reinv...
I would like to make "compressed array"/"compressed vector" class (details below), that allows random data access with more or less constant time.
"more or less constant time" means that although element access time isn't constant, it shouldn't keep increasing when I get closer to certain point of the array. I.e. container shouldn't do ...
Does anybody have some example code showing the pipeline of serializing a std::string sending it through a boost::interprocess::message_queue and getting it back out again?
...
hello,
when i statically add ATL to my visual studio 2008 project - the project is running fine on my station where i develop the project.
when i run the executable for ex. on windows xp the ATL-transformations are not working...
i made a ATL-project in visual studio and added gtkmm-code.
any suggestions?
thanks
...
I'm trying to figure out how to do this. Essentially I have points A and B which I know the location of. I then have point C and point D which I only know the coordinates of C. I know the length of C-D and know that C-D must be parallel to A-B. How could I generally solve for D given A,B,C and length of C-D. Thanks
...
Hi,
I tried to test the "Examining a Message Queue" example in this page:
http://msdn.microsoft.com/en-us/library/ms644928(VS.85).aspx
In order to test it I created a simple window with an edit control and some buttons,
but it doesn't work as I expected, It should Display repeatedly the string "Some Text" in the EditControl until
I ...
suppose we have following function:
void someFunction(int * araye){
for (int i=0;i<5;i++)
cout <<araye[i]<<' ';
cout <<'\n';
}
can we pass an array to this function by following syntax, under upcoming c++0x standards? :
someFunction({1,2,3,4,5});
if that's true, will we even be able to use this syntax in any case in which, arra...
I'm trying to design a macro to produce several related data structures related to things that need initialization. The code has to compile under both C and C++. The goal is to have something like:
MUNGE_THING(struct1);
MUNGE_THING(array1);
turn into something equivalent to
munge_thing((void*)
munge_thing((void*)array1, s...
Code Segment 1:
wchar_t *aString()
{
wchar_t *str = new wchar[5];
wcscpy(str, "asdf\0");
return str;
}
wchar_t *value1 = aString();
Code Segment 2
wstring wstr = L"a value";
wchar_t *value = wstr.c_str();
If value from code segment 2 is not deleted then an memory leak does not occur. However, if value1 from code seg...
I've got a container and would like to erase elements based on a predicate. Erase_if sounds familiar, but I can't find it in C++. What's the name and where is it defined?
I'd like to use it with a lambda in VS10.
...
template <typename vec1, typename vec2>
class fakevector
{
public:
/* Do something */
};
template <class A>
class caller
{
public:
struct typeList
{
struct typeOne
{
//...
};
};
typedef fakevector<typeList::typeOne,int> __methodList; /* This will trigger compile err...