Is there a way in C++ to construct your class such that given a pointer to your class you can instruct dynamic_cast<>() how to cast to another class for which you are wrapping the implementation? Would operator cast do the trick? Imagine I have an Abstract interface base class and derive a concreteA from this as well as concreteB, but ...
I am working on an Operating Systems assignment for one of my summer classes. The teacher has provided an object file that provides functions that mimic the behaviour of a disk device driver. We are then to write a file system API that uses the disk device driver in C.
I am working on my file system format function named Format() which ...
I developed a generic "Unsigned" class, or really a class template Unsigned<size_t N> that models after the C (C++) built-in unsigneds using the amount of uint8_ts as a parameter. For example Unsigned<4> is identical to a uint32_t and Unsigned<32> would be identical to a uint256_t -- if it existed.
So far I have managed to follow most i...
I have some actions... View, Edit, Checkout, etc. Business logic dictates that if a document is already checked out, all Views turn into Edits.
is there a neat OO way to do something like this:
class Action
{
public:
Document document;
virtual void execute();
};
class View, Edit, Checkout : public Action;
View::execute()
{
if (d...
Hello VTK users,
I currently have a project that's in both Java and C++, and part of
the project involves a wrapper using the Java Native Interface (JNI)
where I use functionality from my C++ libraries in the Java code.
Now the problem that I face is, both my Java and C++ codes use VTK
objects - and when I pass down, say a vtkPolyDataA...
I have created an animation which works fine, but it flicks. I need help with double-buffering since I don't know anything about it.
This is the code in my onPaint():
VOID onPaint(HDC hdc)
{
Graphics graphics(hdc);
Pen pen(Color(255, 0, 0, 255));
graphics.DrawEllipse(&pen, sf , 0, 10, 10);
}
It works fine but with ...
I'm developing a Qt-based application and when I use macdeployqt on the bundle, the Qt plugins are not copied to the bundle.
However, if I run it a second time, they are. Additionally, "The svg icon plugin is deployed if the application uses the QtSvg module." is not fullfilled - my application does use QtSvg but the iconengines/* plugi...
I'm using synchronised sockets with a win32 window, and using the send() and recv() function to send data over internet TCP;
what i'm wondering, how would i send some integers or even my own class/structure over the tcp socket? because the send() function only lets me send characters.
Would i just have to send characters and then maybe...
My code has no compilation error. It seems to have a runtime error. In the following piece of code, when the while loop is executed for the first time everything works fine. But on the second iteration, everything stops at "list::iterator k = (temp2->store).begin();". When I comment out the "list::iterator k ..." part everything works fi...
Hello,
What are some good document generators of source (specifically) C++ source code, not including DOxygen.
Thank you,
Scott.
...
I need to provide configuration file, which will describe which STL header files to include. I have found that usually it is done by defining a lot of HAVE_XXX_HEADER macros. I wonder if there's something wrong with explicitly providing header name in a macro. Then instead of testing each variant:
#if defined(HAVE_TR1_UNORDERED_MAP_HEAD...
I would like to build a program which takes a username as parameter and creates the user and its home folder (with some hard-coded specifications like folder, and security checks like username cannot be root or an existing user).
My application needs to create users in order to give SSH access.
The program will be executed using sudo. ...
I need a good way to programmatically set the Pages per Sheet setting when printing.
I know that a user can select this option via a printer settings dialog and that I could make such a dialog display if I wanted to. But in the context of the program I'm working on, I need this to be selected by the software itself without requiring to ...
I have complex polygons which I know the minimum x, minimum y, maximum x and maximum y. I also have another rectangle which I know the top left and bottom right vertices. Knowing this information, how can I know if these 2 bounding boxes are colliding? Thanks
...
Is there some way in Windows to prevent unloading of our dll via FreeLibrary? I.e. to "pin" it in memory for the life of the process?
...
I want to be able to create a function where I specify a parameter to have both a templated container and a templated element type for that container. Is this possible? I get "error C2988: unrecongnizable template declaration/definition" among others. Here is the function in question.
template<class Iter, class Elem>
void readIntoP(...
Diff function on two arrays (or how to turn Old into New)
Example
One[]={2,3,4,5,6,7}
Two[]={1,2,3,5,5,5,9}
Example Result
Diff: insert 1 into One[0], One[]={1,2,3,4,5,6,7}
Diff: delete 4 from One[3], One[]={1,2,3,5,6,7}
Diff: modify 6 into 5 in One[4], One[]={1,2,3,5,5,7}
Diff: modify 7 into 5 in One[5], One[]={1,2,3,5,5,5}
Diff: app...
I'm writing a function which concatenates different numbers of strings depending on their length.
Here is some c++ like pseudo code of what I'm currently doing:
string foo(size_t maxLength)
{
string a, b, c, d, e, ret;
//...assign them
if(a.size() + b.size() + c.size() + d.size() + e.size() <= maxLength)
{
...
I know that size of various data types can change depending on which system I am on.
I use XP 32bits, and using the sizeof() operator in C++, it seems like long double is 12 bytes, and double is 8.
However, most major sources states that long double is 8 bytes, and the range is therefore the same as a double.
How come I have 12 bytes?...
In C++, I understand that the delete operator, when used with an array, 'destroys' it, freeing the memory it used. But what happens when this is done?
I figured my program would just mark off the relevant part of the heap being freed for re-usage, and continue on.
But I noticed that also, the first element of the array is set to null,...