In java, if I want generate a id for a given object, the easyest way I know is to use apache commons:
public class Person {
String name;
int age;
boolean smoker;
...
public int hashCode() {
// you pick a hard-coded, randomly chosen, non-zero, odd number
// ideally different for each class
return new HashCo...
Suppose there is a function with 1000 code of line named LongFunction, and we used it:
bool bSuccess = LongFunction();
assert(bSuccess);
Here I got an assert when debugging, and I know there is something wrong with LongFunction, so I need to find where the function meet problems and returns:
I could probably debug it step by step, i...
I am looking for a library function to convert floating point numbers to strings, and back again, in C++. The properties I want are that str2num(num2str(x)) == x and that num2str(str2num(x)) == x (as far as possible). The general property is that num2str should represent the simplest rational number that when rounded to the nearest repre...
Suppose you have the following code:
int main(int argc, char** argv) {
Foo f;
while (true) {
f.doSomething();
}
}
Which of the following two implementations of Foo are preferred?
Solution 1:
class Foo {
private:
void doIt(Bar& data);
public:
void doSomething() {
Bar _data;
...
if statement looks too awkward, because i need a possibility to increase the number of constatnts.
Sorry for leading you into delusion by that "constant" instead of what i meant.
...
I'am planning to write a sample program which identifies a file (a dll file) locked by / used by some process.
How can we achieve this programmatically using WIN API (a C/C++ function)? Actually, when we are performing some software upgrade process some other process might be using the library which will interim fail the upgrade operati...
hi
in the below code i am getting the c:\windows\Microsoft.Net\Framework\v2.0.057 to the buffer.Now i wnat to store the above value in doble quotes " c:\windows\Microsoft.Net\Framework\v2.0.057" and i want to pass this for the process. how to make this path in double quotes....
HINSTANCE hDLL = LoadLibrary(TEXT("mscoree.dll"));
FN...
Hi all,
I'm coding up a new (personal hobby) app for Windows in c++.
In previous low-level Windows stuff I've used _TCHAR (or just TCHAR) arrays/basic_strings for string manipulation.
Is there any advantage to using _TCHAR over straight up Unicode with wchar_t, if I don't care about Windows platforms pre Win2k?
edit: after submitti...
Hi,
I am trying to read data from a file into an HBufC8 variable and then write the same data
into another file. Here is my testcode; the inner loop of the read repeats 4 times to read
5000 chars in each iteration. However, when I try to write the data back into a file, the
file "testfile.txt" is empty. Will play a little bit more arou...
I'm debugging a C++ Win32 application and I'd like to call an arbitrary Win32 API from the context of that process, as though the program had run this line of code:
DestroyWindow(0x00021c0e);
But entering that into the Immediate Window gives:
CXX0017: Error: symbol "DestroyWindow" not found
Edit: Using the full name of the function...
I'm trying to migrate my code from VSC++ 6 to VSC++ 2008 express edition and from Intel compiler to Microsoft compiler. Everything were easy to migrate except that I'm receiving this errors now:
1>------ Build started: Project: Base, Configuration: Debug Win32 ------
1>Compiling...
1>DefaultScriptReader.cpp
1>Warning: This header is dep...
In C++, is this:
#ifdef COND_A && COND_B
the same as:
#if defined(COND_A) && defined(COND_B)
?
I was thinking it wasn't, but I haven't been able to find a difference with my compiler (VS2005).
...
struct A {
static const int a = 5;
struct B {
static const int b = a;
};
};
int main() {
return A::B::b;
}
The above code compiles. However if you go by Effective C++ book by Scott Myers(pg 14);
We need a definition for a in addition to the declaration.
Can anyone explain why this is an exception?
...
For many years, I have been re-reading John Lakos's classic Large-Scale C++ Software Design. Not only it was the first guidebook of this kind, but it also revolutionized on how systems, developed in C++, are build, managed in an efficient fashion to this day!
Do you feel his ideas are outdated now? Some C++ techniques in the book are ...
Some smart pointer templates, such as boost::shared_ptr, may be instantiated with void to hold an arbitrary object:
http://www.boost.org/doc/libs/1_39_0/libs/smart_ptr/sp_techniques.html#pvoid
Below is a minimal scoped_ptr implementation. When instantiated with void, the compiler complains about an illegal "reference to void" being for...
Hi,
Basically my question is the exact same one as this:
http://stackoverflow.com/questions/937459/simple-client-server-tcp-ip-encrypting-the-message-stream-ssl
The difference is that I need this for pure C++, not .NET. I cannot use 3rd party libraries, so unless it's a Windows system component (like the above) I need something with ...
can someone explain to me how this was done:
http://www.youtube.com/watch?v=ipzR9bhei%5Fo&NR=1&feature=fvwp
what tool did this person use to analyze the midi file? was it a midi file? how did they turn it into this kind of animation?
is it possible to make an application like this in vb.net?
...
Okay, using Qt, I'd like to know how to detect the current state of the mouse at any point in time - without a MouseEvent.
Using QCursor::pos(), you can get its position, but is there a way to determine the current state of the buttons?
Basically, I'm looking to verify the state of the mouse when a timer goes off, so it won't be relate...
When I execute "python" from the terminal with no arguments it brings up the Python interactive shell.
When I execute "cat | python" from the terminal it doesn't launch the interactive mode. Somehow, without getting any input, it has detected that it is connected to a pipe.
How would I do a similar detection in C or C++ or Qt?
...
Two years ago I used eMbedded Visual Studio for Windows CE based application development. I had about 40% app performance acceleration with Intel C++ Compiler(v1.2 or v2.0) in comparison with default MS compiler (floating point issues, ARM). It was looked really helpful for me.
I do remember that downloaded it from official Intel site....