I would expect that if foo is declared in class D, but not marked virtual, then the following code would call the implementation of foo in D (regardless of the dynamic type of d).
D& d = ...;
d.foo();
However, in the following program, that is not the case. Can anyone explain this? Is a method automatically virtual if it overrides a v...
I have a code snippet which connects to a MySQL database like this (not directly from code so there might be typos):
m_connectionHandler = mysql_init(NULL);
if (m_connectionHandler == NULL)
{
// MySQL initialization failed
return;
}
MYSQL *tmp = mysql_real_connect(m_connectionHandler,
m_hostname,
...
I am trying to optimize this sort of things in a heavy computing application:
say I have a
double d[500][500][500][500];
and the following is quite costly at least from compiler perspective
double d[x][y][j][k]
I want to tell compiler is that it's contiguous memory, to facilitate computing the offset.
In my example,
I have s...
In my company we are using one SVN repository to hold our C++ code. The code base is composed from a common part (infrastructure and applications), and client projects (developed as plugins).
The repository layout looks like this:
Infrastructure
App1
App2
App3
project-for-client-1
App1-plugin
App2-plugin
Configuration
project-for-cl...
GLibC has a method semtimedop which allows you to perform an operation (a semaphore acquire in this case) which times out after a certain amount of time. Win32 also provides WaitForSingleObject which provides similar functionalty.
As far as I can see there is no equivalent on OSX or other Unices. Can you suggest either the equivalent fo...
I'm reviewing a quite old project and see code like this for the second time already (C++ - like pseudocode):
if( conditionA && conditionB ) {
actionA();
actionB();
} else {
if( conditionA ) {
actionA();
}
if( conditionB ) {
actionB();
}
}
in this code conditionA evaluates to the same result on both compu...
Hello all
i need to develop simple game that will be using peer to peer connection using centralize index manger server
i know there is problem when client trying to connect other client behind router .
i was reading about NAT traversal that explain mainly theory , but what i really like to see is code examples
c++/java
can you help m...
Looking at http://savannah.gnu.org/projects/nana/ it seems that the last work was done on Nana four years ago, and the official gnu.org homepage for nana is a placeholder. Given how inactive projects tend to suffer from bitrot:
Has the project died?
Is there a successor?
Do folks have a different assertion/logging library for C/C++ ...
I'm trying to figure out a transparent solution for debug halts that repeatedly get hit in my game.
For a trivial example; say I have a halt in my renderer that tells me when I'm trying to use a NULL material. My renderer handles this fine but I still want to know what I'm doing wrong.
This halt will hit every frame now unless I manuall...
Okay, this is just a minor caveat. I am currently working with the lovely ArcSDK from ESRI. Now to get a value from any of their functions, you basically have to pass the variable, you want to assign the value to.
E.g.:
long output_width;
IRasterProps->get_Width(&output_width);
Its such a minor thing, but when you have to pick out ar...
Hello all,
I'm trying to extract the parameter with which an app was called by using the data inside cmdline.
If I start an application instance like this:
myapp 1 2
and then cat the cmdline of myapp I will see something like myapp12.
I needed to extract these values and I used this piece of code to do it
pid_t proc_id = get...
I'm currently working with the Diab 4.4 C++ compiler. It's a total POS, non ANSI-compliant, and I've found problems with it in the past.
I'm wondering if the following problem is an issue with the compiler, or a shortcoming in my knowledge of C++
I realize that the form of x = x && y; will short-circuit the y part if x is false. What t...
I have the following code:
class TimeOutException
{};
template <typename T>
class MultiThreadedBuffer
{
public:
MultiThreadedBuffer()
{
InitializeCriticalSection(&m_csBuffer);
m_evtDataAvail = CreateEvent(NULL, TRUE, FALSE, NULL);
}
~MultiThreadedBuffer()
{
CloseHandle(m_evtDataAvail);
DeleteCriticalSection(&m_csBuffer);
...
Heya,
I'm well aware of using namespaces however, every now and then I'm stumbling upon a using, which uses a specific class. For instance :
#include <string>
using namespace std;
(...)
However - every now and then, I'm seeing :
using std::string;
How should I interpret the "using" in this case ?
Cheers
...
Let's say I have a vector declared like this:
struct MYSTRUCT
{
float a;
float b;
};
std::vector<MYSTRUCT> v;
Now, I want to find all elements of v that share the same a, and average their b, i.e.
Say v contains these five elements {a, b}: {1, 1}, {1, 2}, {2, 1}, {1, 3}, {2, 2}
I want to get v[0], v[1], v[3] (where a is 1) and av...
Hi, I want to implement an progress bar in my C++ windows application when downloading a file using WinHTTP. Any idea how to do this? It looks as though the WinHttpSetStatusCallback is what I want to use, but I don't see what notification to look for... or how to get the "percent downloaded"...
Help!
Thanks!
...
We have developed a C# class library on VS 2008. We want the same functionality as a C++ library on Red Hat Linux. How do we accomplish that?
I am sure we are not the first to migrate C# to C++. Are there any automated tools to convert the source code?
We know about Mono, but we would very much prefer C++ source code.
About 15% is the ...
If I wanted to represent states or options or something similar using binary "flags" so that I could pass them and store them to an object like OPTION1 | OPTION2 where OPTION1 is 0001 and OPTION2 is 0010, so that what gets passed is 0011, representing a mix of the options.
How would I do this in C++? I was thinking something like
enum ...
We need to migrate a unit test harness developed with C# and NUnit to C++ running on Red Hat Linux.
We want to minimize the efforts in migration.
We are reading resources such as this:
http://gamesfromwithin.com/exploring-the-c-unit-testing-framework-jungle
But we don't see anything similar to NUnit.
...
#include <iostream>
using namespace std;
int main()
{
float s;
s = 10 / 3;
cout << s << endl;
cout.precision(4);
cout << s << endl;
return 0;
}
Why the output does not show 3.333 but only 3 ??
...