I'm trying to figure out how to wrap a boost::function member (used as an event callback) of an unmanaged class with a C++/CLI class event. I do not have control over the unmanaged class. All I can do is figure out how to write the C++/CLI class properly.
Here's the example unmanaged class:
class X
{
public:
boost::function<void ...
I am trying to write a c++ program in linux.In which i want to make a 3D image upside down. where i have the coordinates (x,y,z) of the image .
Example:
^ |
| to |
| V
How to do it?
...
I saw some code as below during a peer-code-review session:
char *s = new char[3];
*s++ = 'a';
*s++ = 'b';
*s++='\0';
delete []s; // this may or may not crash on some or any day !!
Firstly, I know that in Standard C++, pointing to one-past the array-size is O.K. though accessing it results in undefined behaviour. So I b...
I want to be able to initialize a vector of a size 'SIZE' before main. Normally I would do
static vector<int> myVector(4,100);
int main() {
// Here I have a vector of size 4 with all the entries equal to 100
}
But the problem is that I would like to initialize the first item of the vector to be of a certain value, and the othe...
I have been teaching some bright high school kids Python for 3 months now (for most of them this was their first experience with programming). I've decided to take the best of the group of give them a quick (120 minute) introduction to C++. They're hard-working enough to take what we give them and learn things further on their own.
Are ...
I need to write a simple parser to a sort of Domain Specific Language.
It needs to have basic arithmatics with proper operators evaluation order and a syntax to call functions of the underlying environment which can be overloaded.
What is the simplest way to write such a parser? Is there something I can adapt or use out of the box? I'm w...
Say I have some C++ project which builds an exe or dll file. The project is checked into a SVN repository. I want to automatically synchronize the revision from SVN with the version resource embedded in my exe/dll file, i.e. the version should be something like $major.$minor.$svn_revision.
Any ideas on how to achieve this? Are there any ...
If my application is out of memory when i call new() i will get exception and malloc() i will get 0 pointer.
But what if i call a method with some local variables? They occupy memory too. Is there some way to reserve memory for "normal" variables? So that even though new() throws exception i can just catch it, fix stuff and still call m...
I've gotten some C++ code to work with the TinyXML parser. However, to do this I had to include the source code from TinyXML with my regular source code. I'd like to have TinyXML included as a separate library. I'm using Eclipse with the Cygwin C++ compiler. What's a good way to do this?
...
Everyone should know about boost. What are other helpful libraries for C++? If you need to mention specifics (like libcurl, freeimage) please note what they are specific to (web protocol, image loading).
...
I need an example of the shortest path of a directed cyclic graph from one node
(it should reach to all nodes of the graph from a node that will be the input).
Please if there is an example, I need it in C++, or the algorithm.
Thanks very much.........
...
I've been programming in C and C++ in Linux for around 3 years, and recently have been interested in developing commercial software for businesses. Let's say I've found a niche where I think I could be successful, but that they only use Windows. I have no experience whatsoever with the Windows API, however. I have a few questions:
Sh...
Is it possible to make a keyboard hook work on all desktops? For example, could I make it record keys on the winlogon desktop and interactive desktop at the same time? If so how? Thanks for the help!
EDIT: Figured it out. I modified ctrl2cap driver to log keys.
...
class foo
{
public:
void say_type_name()
{
std::cout << typeid(this).name() << std::endl;
}
};
int main()
{
foo f;;
f.say_type_name();
}
Above code prints P3foo on my ubuntu machine with g++. I am not getting why it is printing P3foo instead of just foo. If I change the code like
std::cout << typeid(*this).name() <...
I have a C++ program that crashed due to a bug. It would not even get to main as a NULL pointer was accessed in one of its static global object's contructor functions. To make matters worse the pointer was NULL but should have been set by another global static variable. I think I can wrap those globals in a function that sets global p...
I'm looking for a way to rotate a string in c++. I spend all of my time in python, so my c++ is very rusty.
Here is what I want it to do: if I have a string 'abcde' I want it changed to 'bcdea' (first character moved to the end).
Here is how I did it in python:
def rotate(s):
return s[1:] + s[:1]
I'm not sure how to do it in cpp....
Hello,
I seem to be having a very frustrating time with an inherited class calling an explicit superclass constructor. I just can't seem to get the syntax right!
All the examples I have seen on the matter so far do not separate out the header and in-line class definition (using {}'s) from forward-declarations with a header file, so I'...
What do you think? Is this correct or are there memory leaks?
Source:
#include <QList.h>
#include <boost/shared_ptr.hpp>
#include <iostream>
class A {
private:
int m_data;
public:
A(int value=0) { m_data = value; }
~A() { std::cout << "destroying A(" << m_data << ")" << std::endl; }
operator int() const { return m_data...
Hello,
I am using Python as a plug-in scripting language for an existing C++ application. I am able to embed the python interpreter as stated in the Python documentation. Everything works successfully with the initialization and de-initialization of the interpreter. I am, however, having trouble loading modules because I have not been a...
Is there a platform-independent method to embed file data into a c++ program? For instance, I am making a game, and the levels are stored in text format. But I don't want to distribute those text files with the game itself. What are my options?
...