Hello, I would like to do something like:
for(int i=0;i<10;i++)
addresses[i] = & function(){ callSomeFunction(i) };
Basically, having an array of addresses of functions with behaviours related to a list of numbers.
If it's possible with external classes like Boost.Lambda is ok.
Edit: after some discussion I've come to conclusion...
Hi,
How to translate properly the following Java code to C++?
Vector v;
v = getLargeVector();
...
Vector getLargeVector() {
Vector v2 = new Vector();
// fill v2
return v2;
}
So here v is a reference. The function creates a new Vector object and returns a reference to it. Nice and clean.
However, let's see the following C...
I have the following source files:
//test1.cpp
#include <iostream>
using namespace std;
inline void foo()
{
cout << "test1's foo" << endl;
}
void bar();
int main(int argc, char *argv[])
{
foo();
bar();
}
and
//test2.cpp
#include <iostream>
using namespace std;
inline void foo()
{
cout << "test2's foo" << endl;
}
void ...
Hi There,
Thanks for having a look at question.
I am trying to invoke a java method which is in class files using JNI interface. In turn the called class file should be executing the another .jar file which resides in the same direcotry ? I had hard time acheiving this and I am unsuccessful in executing the .jar file. I mean I am not abl...
I wrote a line drawing algorithm using the wu technique. It works but has issues. See below.
What I'm wondering is if anyone has tackled the problem of drawing anti-aliased lines? Suprisingly, a google search results in no satisfactory algorithms. Lots of discusions, but not a single complete, robust algorithm, independent of any dep...
Hi,
I've been trying to find out the fastest way to code a file copy routine to copy a large file onto a RAID 5 hardware.
The average file size is around 2 GB.
There are 2 windows boxes (both running win2k3). The first box is the source, where is the large file is located. And the second box has a RAID 5 storage.
http://blogs.technet....
When talking about Return Value Optimisation (RVO), various texts mention exception cases related to the return of Named Objects. So in short:
What are they?
Is there a definition for this term in the current c++ standard?
Side note: I've tried to add the following tags: RVO and NRVO but due to lack of reputation points I wasn't abl...
Hi,
I've been trying to learn more about private inheritance and decided to create a string_t class that inherits from std::basic_string. I know a lot of you will tell me inheriting from STL classes is a bad idea and that it's better to just create global functions that accept references to instances of these classes if I want to extend ...
i have a c program below:
#define f(g,g2) g##g2
main()
{
int var12=100;
printf("%d",f(var,12));
}
when i run just the preprocessor it expands this as
{
int var12=100;
printf("%d",var12);
}
which is the reason why the output is 100.
can anybody tell me how/why the preprocessor expands var##12 to var12?
...
From the following code, If RVO has happened, I expect to see the 2 addresses pointing to the same location, however this is not the case (my compiler is MS VC9.0)
#include <iostream>
#include <string>
std::string foo(std::string& s)
{
std::cout << "address: " << (unsigned int)(&s) << std::endl;
return s;
}
int main()
{
std::...
I'm sure I'm making this harder than it needs to be.
I have a vector...
vector<Joints> mJointsVector;
...comprised of structs patterned after the following...
struct Joints
{
string name;
float origUpperLimit;
float origLowerLimit;
};
I'm trying to search mJointsVector with "std::find" to locate an individual joint...
I have read the existing questions on external/internal linkage over here on SO. My question is different - what happens if I have multiple definitions of the same variable with external linkage in different translation units under C and C++?
For example:
/*file1.c*/
typedef struct foo {
int a;
int b;
int c;
} foo;
foo xy...
Is it possible to handle exceptions in these scenarios:
thrown from constructor before entering main()
thrown from destructor after leaving main()
...
Do streflop or boost libraries change the definition of std::min?
I have a project that compiles fine with g++/make UNTIL I merge it with the CMake build of another project (using add_directory). Suddenly I get:
no matching function for call to min(double&,float)
The line number it claims the error is on is wrong (it's pointing to th...
I'm using C++/boost::asio under Win7.
I'm trying to "sniff" trafic over a given TCP/IP port. Hence, I'd like to listen on that port, receive messages, analyze them, but also immidately allow them to flow further, as if I never intercepted them. I want them to sink into the program that normally listens and connects on that port. Imagine...
In Qt, when moving a QToolBar, one can use the QToolBar::topLevelChanged(bool) signal to know if the the QToolBar is floating or docked.
When the QToolBar is docked, how can one get the Qt::ToolBarArea (LeftToolBarArea, RightToolBarArea, TopToolBarArea, BottomToolBarArea) where the QTookBar is docked?
Thanks.
...
I'm using the following code to resize a bitmap using GDI+ in C. I'm getting gray values for the top edge even for images where that area should be white. The problem disappears when the interpolation is nearest neighbor. However, I tried bicubic interpolation with ImageMagick and it seems fine. Any limitations problems I should know of...
Possible Duplicate:
C/C++: How to make a variadic macro (variable number of arguments)
Just wondering if this is at all possible., so instead of how im currently handling logging and messages with multiple parameters im having to have a number of different macros for each case such as:
#define MSG( msg ...
Does the Eclipse CDT C++ editor have a means of supporting the Altivec C++ language extensions, as implemented for example in the GNU g++ compilers when compiling with -maltivec?
Specifically, can it be made to stop reporting the vector data types as syntax errors?
e.g.
vector unsigned char foo;
declares a 128-bit vector variable nam...
Hi all!
I'm having problems attaching to a process spawned from one of my own processes. When I attempt to attach to the process using Visual Studio 2005 (Debug -> Attach to process) I receive the error message: "Unable to attach to the process. The system cannot find the file specified."
In my program, I spawned the process that I lat...