c++

C++ cannot convert from base A to derived type B via virtual base A

I have three classes: class A {}; class B : virtual public A {}; class C : virtual public A {}; class D: public B, public C {}; Attempting a static cast from A* to B* I get the below error: cannot convert from base A to derived type B via virtual base A ...

How to specify a preprocessor directive in eclipse?

How are preprocessor directives specified in eclipse for different configurations? For instance if I have multiple mains that should be run in different configurations and specify #ifdef Problem1 //main func #endif /*Problem1*/ Note that this is with managed makefiles ...

Populate a QTextDocument from a .odt file

Hi, I am writing a rich text editor using C++ and Qt. For now, I would like it to support (at least) the .odt format. I found QTextDocumentWriter for writing the contents of the QTextDocument to a file, but I can't seem to find anything to read that back into the QTextDocument, which obviously makes saving it sort of useless in the firs...

Problems initializing pthreads

Hi, I'm debugging a program using pthreads for a class I have to solve a producer consumer problem. What I'm running into is that I get an error saying that I have a undefined reference to the create a join functions. After that I put the initialization functions in but now I get the error that none of them were declared within the scop...

drawing a simple triangle with a while loop

Back learning after silly life issues derailed me! I decided to switch my learning material and I'm now working through Accelerated C++. Chapter 2, Exercise 5: Write a set of "*" characters so that they form a square, a rectangle, and a triangle. I tried but just couldn't get the triangle down exactly. A quick google found the followi...

C++ program to count number of objects in a particular Linux directory

I'm attempting to write a program in Linux using C++ that counts the number of files and folders in a user specified directory, but the more I read, the more confused I get. I'm new to C++ and to programming in general, and I understand that I have a big hurdle to vault at the start, but I'm not entirely sure where to start reading on th...

Calling C++ function from JavaScript script running in a web browser control

I have embedded a web browser control in my c++ application. I want javascript running in the web browser control to be able to call a c++ function/method. I have found mentions of three ways to do this: Implement an ActiveX component that acts as a middle man. (Implementation details here: http://blogs.msdn.com/b/nicd/archive/2007/04...

Are there any libraries that can generate a 3D mesh from a 3D array of data?

I am trying to write some code that takes some data, puts it into a 3-dimensional array, and then generates a 3D mesh for rendering. The data is a list of tiles with fields for defining the tile's type, etc. I am using Irrlicht for graphics right now and it has ways to manipulate the vertices/indices of a mesh but I can't come up with a ...

c++. compile error. am trying to add friend template function with enum template parameter

Hello, dear programmers! Please help with the next code: typedef enum {a1, a2, a3} E; template<E e> int foo() { return static_cast<int>(e); } class A { A() {}; friend int foo<E e>(); }; The compiler says: error C2146: syntax erorr: missing "," before identifier "e" I would be glad if someone could explain my mistake. ...

What does const denote here?

What does const denote in the following C++ code? What is the equivalent of this in C#? I code in C# and I am trying to learn C++. template <class T> class MaximumPQ { public: virtual ~MaximumPQ () {} virtual bool IsEmpty () const = 0; virtual void Push(const T&) = 0; virtual void Pop () = 0; }; ...

How to generate a ppt file from my C++ program (Linux)

Possible Duplicate: How can I programmatically create PowerPoint presentations. On Linux. For Free. hello, do anyone know how to generate a PPT file (powerpoint) from a simple C++ program?? i have the Idea, but i really dont know the "How To". I installed openoffice SDK, and i know that openoffice exports to *.ppt format. T...

std::vector iterator invalidation

There have been a few questions regarding this issue before; my understanding is that calling std::vector::erase will only invalidate iterators which are at a position after the erased element. However, after erasing an element, is the iterator at that position still valid (provided, of course, that it doesn't point to end() after the e...

Confusion over C++ pointer and reference topic

What is the difference between the following parameter passing mechanisms in C++? void foo(int &x) void foo(int *x) void foo(int **x) void foo(int *&x) I'd like to know in which case the parameter is being passed by value or passed by reference. ...

How to get information about network adapters in c++?

How to get information about all network adapters in system? Name, Manufacturer, Location(PCI, slot2), Driver Version. Actually i retrieved Name and Manufacturer with WMI but i can't find Location and Driver version. I need only c++ solutions not MFC/clr. winapi function? wmi (missing something)? Also i need to retrieve .NET version on ...

Starting a service?

Well, I've recently been getting into developing drivers, so I thought I should make a class to programmatically start services. But of course, I ran into some trouble on the way, as usual. I'm using StartService to start it, but for some reason it just hangs, I've done some research over the internet and it seems it waits for ensurance...

QAbstractItemModel for QMetaObject, do I have to write it myself?

A suite of data models built on top of Qt's reflection system seems like a natural synergy, but I haven't found such a beast in the Qt library itself or from a 3rd party. Does anyone know if such a thing exists? I'm look for data models for editing and displaying a collection of QObjects QMetaObject properties. I can kind of understand ...

error: expected unqualified-id before ‘public’

I have read a few posts but cannot figure out what is wrong.My Code is a s follows #include <iostream> using namespace std; /* compiles with command line gcc xlibtest2.c -lX11 -lm -L/usr/X11R6/lib */ #include <X11/Xlib.h> #include <X11/Xutil.h> #include <X11/Xos.h> #include <X11/Xatom.h> #include <stdio.h> #include <mat...

How to debug uninitialized variables in VC++

Hi, How to debug uninitialized variables in release mode in C++. ...

Where are all the esoteric collection template libraries?

Suppose I want a collection type that isn't really supported by anything in the STL or by BOOST, like a spacial index or a fibonacci tree (if i think that might be useful on my really big dataset). Is there a good place to find these kinds of less common tools? ...

Rounding off floats with ostringstream

Hi, I have an issue regarding conversion from float to c++ string using ostringstream. Here is my line: void doSomething(float t) { ostringstream stream; stream << t; cout << stream.str(); } when t has value -0.89999 it is round off to -0.9, but when it's value is 0.0999 or lesser than this say 1.754e-7, it just prints w...