I'm getting a compiler error with bind:
using namespace std;
bool odp(int arg1, int arg2);
// ...
find_if(vec.begin(), vec.end(), tr1::bind(odp, iValue, _1)); // C2065
My goal is to curry odp(), so its first argument is iValue, and apply that function in find_if.
The error:
C2065: '_1' : undeclared identifier.
What am I doing w...
Hello. I am writing a program for class that is asking us to create a class of "book". We are then supposed to create new instantiations of that class upon demand from the user. I am new to C++ so I am attempting to code this out but am running into a problem.
The main problem is how do I instantiate a class with a variable if I do...
Let's say I have a base class Animal from which a class Cow inherits, and a Barn class containing an Animal vector, and let's say the Animal class has a virtual function scream(), which Cow overrides.
With the following code:
Animal.h
#ifndef _ANIMAL_H
#define _ANIMAL_H
#include <iostream>
using namespace std;
class Animal {
public:
...
I'm embarrassed to post this but it's been awhile since I worked in C++, been with C# for awhile. I'm converting old (not written by me) vs2003 and 05 C++ code to vs 08. In addition to lots of lumps during conversion, I want to add debug logging so I can monitor what is going on when I attach with windbg. I've searched the archives here ...
The code I have looks like this (all uses of done shown):
bool done = false;
for(int i = 0; i < big; i++)
{
...
for(int j = 0; j < wow; j++)
{
...
if(foo(i,j))
{
done = true;
break;
}
...
}
if(done) break;
...
}
will any compilers convert it to this:
for(int i = 0; i < big; i++)
{
...
...
I have an object which has both a copy constructor and assignment operator defined. It is enclosed inside a shared pointer.
I want to make another shared pointer that contains a copy of the original shared pointer (i.e. new shared pointer to a new memory location, which however, has the same data as the original object).
Thanks for an...
I am receiving this error
>GXRenderManager.obj : error LNK2001: unresolved external symbol "private: static class GXRenderer * GXRenderManager::renderDevice" (?renderDevice@GXRenderManager@@0PAVGXRenderer@@A)
The following is my code...
GXDX.h
class GXDX: public GXRenderer {
public:
void Render();
void StartUp();
};
GXGL....
I want to turn a screen shot from the clipboard into a array data (Red/Green/Blue) in my program. so i guess it's as simple as that. but i don't want to use anything else then the print screen and clipboard if i can?
anyway any questions just ask.
...
Is there any advantage in using file writing with overlapped IO in Windows, vs just doing the file writing in a separate thread that I create?
[Edit - please note that I'm doing the file writes without system caching, ie I use the FILE_FLAG_NO_BUFFERING flag in CreateFile)
...
I know it's possible to separate to create a pointer to member function like this
struct K { void func() {} };
typedef void FuncType();
typedef FuncType K::* MemFuncType;
MemFuncType pF = &K::func;
Is there similar way to construct a pointer to a const function? I've tried adding const in various places with no success. I've played ...
I just read that we should not use virtual function excessively. People felt that less virtual functions tends to have fewer bugs and reduces maintenance.
I'm not able to get what kind of bugs and disadvantages can appear due to virtual functions.
EDIT :
One reason I can think of is virtual function may be slow than normal function due...
What should I learn after learning C++?
I have read C++ from books like C++ Primer, Effective C++ etc but now I want to learn some advanced topics.
So what should I learn now,any suggestions?
...
I have a 2D list of vectors (say 20x20 / 400 points) and I am drawing these points on a screen like so:
for row in grid:
for point in row:
pygame.draw.circle(window, white, (particle.x, particle.y), 2, 0)
pygame.display.flip() #redraw the screen
This works perfectly, however it's much slower then I expected.
I want to...
Hello :)
I'm writing a simple wrapper around the Win32 FILETIME structure. boost::datetime has most of what I want, except I need whatever date type I end up using to interpolate with Windows APIs without issues.
To that end, I've decided to write my own things for doing this -- most of the operations aren't all that complicated. I'm i...
During testing I have a mock object which sets errno = ETIMEDOUT; The object I'm testing sees the error and calls strerror_r to get back an error string:
if (ret) {
if (ret == EAI_SYSTEM) {
char err[128];
strerror_r(errno, err, 128);
err_string.assign(err);
} else {
err_string.assign(gai_strerror...
I have an a.dll (not modifiable as i do not have the source) with a function bool openPort(DWORD mem).I wrote a c++ main, loaded this dll using LoadLibrary, and the function works well.It returns true.
Now, I need to call this function from Java via JNI.
I wrote another b.dll with a function like so
JNIEXPORT void JNICALL Java_MyClass_...
How do I cast Qt's QVariant to boost::any?
...
Hi, I have been trying to execute this program on my migw ,through code::blocks,
#include <string.h>
#include <math.h>
#include <stdio.h>
#define N 100
int p[N];
int pr[N];
int cnt;
void sieve()
{
int i,j;
for(i=0;i<N;i++) pr[i]=1;
pr[0]=pr[1]=0;
for(i=2;i<N;i++)
if(pr[i])
{
p[cnt]=i; cnt++;
...
How is the scope of a variable/identifier maintained in the symbol table of a c/c++ compiler.
Please suggest some good links and books to know the how compiling process of c/c++
program is implemented for better understanding.
...
Hi, I am new to Xcode.
I am writing a C++ command line project. I used to use netbean. For example if I use a string, then I should be able to invoke the string library API function in a popup list for me to choose to autocomplete. So now I don't know how to do that in Xbox. Can some one help? My question is specific: how to find ...