c++

C++: Equivalent to "using namespace <namespace>" but for classes?

Suppose you have a class with an enum defined within it: class MyClass { typedef enum _MyEnum{ a } MyEnum; } Is there a way to access the value a from another class without having to refer to it as MyClass::a? If the enum were contained within a namespace rather than a class, than "using namespace ;" solves the problem - is there a...

static member variable and method

If I have a C++ class which contains a static member variable, does the accessor method for this variable need to be static as well? Also, are there any issues that might occur if I inline this method? ...

Why would you use the __LINE__ macro in C++

I am trying to figure out how people use the __LINE__ macro at work. How do you guys use it? ...

FLTK in Cygwin using Eclipse (Linking errors)

I have this assignment due that requires the usage of FLTK. The code is given to us and it should compile straight off of the bat, but I am having linking errors and do not know which other libraries I need to include. I currently have "opengl32", "fltk_gl", "glu32", and "fltk" included (-l), each of which seem to reduce the number of e...

How can I manage a group of derived but otherwise Unrelated Classes.

It seems the more I talk about this problem the better I understand it. I think my previous question didn't convey what I am trying to do correctly. My apologies for that. In my design I have GameObjects which are essentially an aggregation class, all functionality in a GameObject is implemented by adding various "Features" to it. A Fea...

C/C++ h264 or ON VP6 open source video encoder

C/C++ h264 or ON VP6 open source video encoder with capability of turning bmp's/png's or jpegs into video frames What do I need Open Source Libs for encoding. Tutorials and blog articles on How to do it, about etc. PS It should be SMALL SIZE!) (Not a mountain like FFMPEG) ...

How do I convert a c++ string to a .NET String^ ?

I've been trying to figure out how to convert a string to a String in Visual Studio 2005 with no luck. Here is the relevant code: #include <string> using namespace std; #using <System.dll> using namespace System; string test = "a test string"; So I'm trying to convert test into a String^ to use inside other .NET classes, can anyone ...

Can an ifstream variable be a global variable?

// stream from file. ifstream file; int main (int argc, char * argv[]) { // get argument passed from command line // This is file name if (argc != 2 ) { cout << "use: ./executable <filename>"; }else { //cout << "You are using filename: " << argv[1]; // start the file stream file (argv[1]); } Is there any reason why file(argv[1...

Is the memory allocated by new operated consecutive?

as the title says, I want to know in c++, whether the memory allocated by one new operation is consecutive... ...

C++: difference between reference and const conreference as function parameter?

Here is a simple snippet of C++ code A foo(){ A a; // create a local A object return a; } void bar(const A Why does the argument of function bar have to be a const reference,not just a reference? Edit1: I know that reference is to avoid copying overhead. and const is for read-only. But here I have to make it a const referenc...

Doxygen - function not documented should not be viewable/displayed in the list - Issue document only for documented entities

class EXAMPLE{ public func1() private func2() func3() } I have checked for documented entities only. I have documentation for func1 and func3 but no documentation for func2. I have EXTRACT_ALL = NO EXTRACT_PRIVATE = NO EXTRACT_STATIC = NO EXTRACT_LOCAL_CLASSES = YES EXTRACT_LOCAL_METHODS = NO ...

Is there a freeware utility out there to monitor a c++ application for memory leaks?

I am verifying an application coded in c++ with memory leak and need a utility (freeware) I can easily run to detect where it is ocurring. any ideas? ...

Why is this syntax invalid? vectorPointer->[0]

In C++, why is the following element access in a vector invalid? void foo(std::vector<int>* vecPtr) { int n = vecPtr->size(); // ok int a = vecPtr->[0]; // invalid } Instead, we have to write the more cumbersome (*vecPtr)[0] = 1; I think, the operator[] call should just have the same syntax like a method call, and I hate t...

C++ Server is terminating if the front end Tomcat is killed. Error "Received untrapped signal [13] - SIGPIPE"

I am facing a problem in my C++ server program. The request XML comes from the front end (Java) and the back end server (C++) process the request and returns the reply XML. As part of testing after submitting the request to back-end we killed the Tomcat server. The back-end application (threaded server application) after processing the ...

Preparation for a C++ interview

i have to prepare for an interview in C++ technology. could you please drop in your suggestions and recommendations about how to start and what are the basic topics that i have to concentrate mostly on? i have a prior knowledge on the topics but i am confused with what to concentrate on as C++/C are very vast.also i think that i have to ...

Supporting multi-add/delete (and undo/redo) with a QAbstractItemModel (C++)

Greetings, I've been writing some nasty code to support the undo/redo of deletion of an arbitrary set of objects from my model. I feel like I'm going about this correctly, as all the other mutators (adding/copy-pasting) are subsets of this functionality. The code is nastier than it needs to me, mostly because the only way to mutate the...

Speed difference: separate functor VS operator() inside a big class with *this

I'm using the c++ STL heap algorithms, and I wrote a wrapper class around it so I could do some other stuff. When I tried to use the code below, for example: //! Min-heap wrapper class. class FMMHeap{ public: FMMHeap(Vector &phi) : _phi(phi) {} bool operator()(unsigned p1, unsigned p2) {return fabs(_phi(p1)) > fabs(_phi(p2)); }...

Looking for a disk-based B+ tree implementation in C++ or C

Hi, I am looking for a lightweight open source paging B+ tree implementation that uses a disk file for storing the tree. So far I have found only memory-based implementations, or something that has dependency on QT (?!) and does not even compile. Modern C++ is preferred, but C will do too. I prefer to avoid full embeddable DBMS solut...

C++ nested macros?

Is there any way, in C++, to define nested macros/constants within a class, in a similiar fashion to nested typedefs, or a method to acheive similiar functionality? The motive is generally for the macros to be used by templates. class SomeClass { public: #define SomeConstant 123 }; int x=SomeClass::SomeConstant; Ofcourse, static ...

Why not resize and clear works in GotW 54?

Referring to article Gotw 54 by HerbSutter, he explain about 1.Tthe Right Way To "Shrink-To-Fit" a vector or deque and 2.The Right Way to Completely Clear a vector or deque Can we just use container.resize() and container.clear() for above task or Am I missing something. ...