In a C++ program I write:
#include<iostream>
#include<vector>
using namespace std;
int main()
{
vector<int> a;
a.resize(1);
for( int i = 0 ; i < 10 ; i++ ) {
cout << a[i] << " ";
}
return 0;
}
this program prints the correct value of a[0] (because it is allocated) but also prints values at the rest of the 10 lo...
Are there any standard protocols with witch you could make games with (like http, ftp), as i had problems when I tested a connection on a random port (1024-65300) out (I had to forward ports on my router and it only works with one computer at a time).
There should be, im programs use something and there is no need to set up any ports......
Why does this not compile on VC 2005?
bool isTrue(bool, bool) { return true; }
void foo();
#define DO_IF(condition, ...) if (condition) foo(__VA_ARGS__);
void run()
{
DO_IF(isTrue(true, true)); // error C2143: syntax error : missing ')' before 'constant'
}
Running this through the preprocessor alone outputs:
bool isTrue(bo...
Summary:
Have you ever made an interface between two -- or better yet even more -- different physics toolkits? For a online game (or at least with network physics)? How did it turn out? Lessons learned? Is it better to rewrite large chunks of code elsewhere, or did the investment pay off?
Bloat:
I'm using ODE physics toolkit for my in...
boost::bind handles boost::shared_ptr the same way as raw pointers.
QObject * object(new QObject);
boost::shared_ptr<QObject> sharedObject(new QObject);
bind(&QObject::setObjectName, object, _1)( "name" );
bind(&QObject::setObjectName, sharedObject, _1)( "name" );
I would love to have a boost::bind that handles QPointers as raw poi...
If I have a vector toto, when I write toto.s , IntelliSense gives me toto.size but I would like toto.size(). How to force IntelliSense to give me parentheses?
...
I need to change my Qt application's dock icon (in MacOS X) in run-time according to some conditions.
I've found several recipes on trolltech.com:
QApplication::setIcon()
setApplicationIcon()
qt_mac_set_app_icon()
but none of it works: there is no such methods/functions in Qt 4.5.
How can I change my application's dock icon and wha...
Hello everyone, i'm new to programming.. and i'm stuck at a problem.. I want my program to identify the separate digits in a given number, like if i input 4692, it should identify the digits and print 4 6 9 2. And yeah, without using arrays..
Thanks in advance!
...
I want to get the process's user name and check if it is a local administrator . Or check directly if the current procees user is a local administrator
...
Python's itertools tools implements a chain iterator which essentially merges a number of different iterators into a single one.
Is there something similar in C++ ? A quick look at the boost libraries didn't reveal something similar, which is quite surprising for me. Is it difficult to implement this functionality ?
...
Problem Statement:-
I am inserting a record into Oracle if that record is already present(duplicate==>primary key is present) in database
i want to update it with new one.
Currently to solve this while inserting the record if i get OCI_ERROR then i call
OCIErrorGet( (dvoid *)errhp, (ub4) 1, (text *) NULL, &errcode,errbuf, (ub4) size...
I know that when Windows is shutting down, it sends a WM_QUERYENDSESSION message to each application. This makes it easy to detect when Windows is shutting down. However, is it possible to know if the computer going to power-off or is it going to restart after Windows has shutdown.
I am not particularly hopeful, considering the document...
In C++ throw; when executed inside a catch block rethrows the currently caught exception outside the block.
In this answer an idea of exception dispatcher is brought up as a solution to reducing code duplication when using complex exception handling often:
try {
CodeThatMightThrow();
} catch(...) {
ExceptionHandler();
}
void E...
We have a class hierarchy which looks something like this:
class base
{
};
class derived1 : protected base
{
private:
float m_price;
int m_quantity;
float m_value;
public:
// float calculateValue();
};
class derived2 : protected base
{
private:
double m_price;
long m_quantity;
double m_value;
public:
// doubl...
This code fails at runtime in the copy constructor.
But the compiler (MSVS2008) issues no warnings.
Could you explain (preferably cite the standard) whether this code is illegal or what?
I understand that A a = a; should never be written at the first place,
but I am looking for a theoretical background.
class A
{
public:
A...
Hi,
can anyone recommend portable SIMD library that provides a c/c++ API, works on Intel and AMD extensions and Visual Studio, GCC compatible. I'm looking to speed up things like scaling a 512x512 array of doubles. Vector dot products, matrix multiplication etc.
So far the only one I found is:
http://simdx86.sourceforge.net/ but as t...
Hi All,
After asking this question and apparently stumping people, how's about this for a thought-- could I give a buffer from a C# application to a C++ dll, and then have a timing event in C# just copy the contents of the buffer out? That way, I avoid any delays caused by callback calling that apparently happen. Would that work, or d...
I saw an answer to a question regarding timing which used __sync_synchronize().
What does this function do?
And when is it necessary to be used?
...
I have a program written in C++ which does some computer diagnostics. Before the program exits, I need it to launch Internet Explorer and navigate to a specific URL. How do I do that from C++?
Thanks.
...
Say you're writing a C++ application doing lots of floating point arithmetic. Say this application needs to be portable accross a reasonable range of hardware and OS platforms (say 32 and 64 bits hardware, Windows and Linux both in 32 and 64 bits flavors...).
How would you make sure that your floating point arithmetic is the same on all...