c++

How to view source code of header file in C++?

similar to iostream.h ,conio.h , ... ...

Private virtual method in C++

What is the advantage of making a private method virtual in C++? I have noticed this in an open source C++ project: class HTMLDocument : public Document, public CachedResourceClient { private: virtual bool childAllowed(Node*); virtual PassRefPtr<Element> createElement(const AtomicString& tagName, ExceptionCode&); }; ...

How does the following foward-declared multi-inheritance pointer converted code work?

In the followint code, how does the pointer conversion & multi-inheritance play together? class Foo { public: virtual void someFunc(); }; class Bar; void someWork(Bar *bar) { ((Foo*) bar)->someFunc(); } class Bar: public Zed, public Foo { ... virtual void someFunc() { ... do something else ... } } Bar bar; int main() { som...

Guarantees on address of baseclass in C++?

In C struct's, I'm guaranteed that: struct Foo { ... }; struct Bar { Foo foo; ... } Bar bar; assert(&bar == &(bar.foo)); Now, in C++, if I have: class Foo { ... }; class Bar: public Foo, public Other crap ... { ... } Bar bar; assert(&bar == (Foo*) (&bar)); // is this guaranteed? If so, can you give me a reference (like "The ...

Dynamic array allocation in C++ question

I have a struct of type Duplicate I have a variable of type int called stringSize, it has a value of 5 I am creating a dynamic array: Duplicate *duplicates; duplicates = new Duplicate[stringSize - 1]; Later I delete[] duplicates; I'm getting one member in that array only? I've verified that stringSize - 1 = 4 with a debug walk throug...

Seeking tool to graphically show (header) file dependancies in C/C++

I know that header guards avoid (most) trouble; call me @n@l if you like, but I just don't like a sloppy header-file tree. If I draw on paper a box for each header file and connect them by lines representing #include, I like to see a neat hierarchy. But what I usually see is a complex web. Maybe I am @n@l, but to me that tangled ...

how to change address of variable?

i have Tree<std:string> tree; now new Tree<std:string>; leads to a pointer, how can i change address of tree to that of pointer generated by new? ...

bad_alloc in detail?

Hi, I work on a game project. Recently, we run into a problem which we catch a "bad_alloc" exception when we load/unload different scenes for about three times. Eachtime we load a scene, we first load the compressed .zip folder into the memory and then extract game objects from it. Since we don't have any memory profiler tool, I simply...

how c++ implements the polymorphism internally?

Respected Sir! i should tell you that what i know and what i don't know about the asked question so that you can address the weak area of my understanding. i know that c++ implements the polymorphism by using the Vtable which is array of pointers each pointer points to the virtual function of the class, each class in the hierarchy has...

Declaring a variable as a "Class" datatype, without calling the "Class" constructor?

Forgive me if I'm just blatantly missing something, but I'm trying to make the transition from structs and c to classes and c++. Heres what I'm trying to do: A have a "Checkers" class and a "Board" class. Now with structs, I could just create an array of Checkers in my "board.cpp" file by doing: Checker checkers[2][12] (0 and 1 for ...

standalone tool for generating makefile(s) from Eclipse's .cproject file?

Is there a standalone tool, that can be ran from a shell script, to generate a makefile from the .cproject? Actually, the same functionality as the CDT itself, but that can be non-interactive. As is probably obvious, I want to be able to run a script that checkouts and builds the software, comprising from several C++ project. I am tryin...

how c++ implements dynamic binding internally ?

Respected Sir! please explain how c++ implements this dynamic binding a pictorial representation would be more useful in understanding perspective. or suggest a websigt which contains pictorial representations and full detail about this topic. ...

Array class in C++: How to use one method in another

I have a class for performing various array operations. I like to use my insert method in my populate method. Can someone guide me on that? Here is the code: #include <iostream> #include <cstdlib> using namespace std; const int MAX=5; class array { private: int arr[MAX]; public: void insert(int pos, int num); void populat...

Release socket in Boost.Asio (opposite of assign), or not transfer ownvership

Hello, There is a function assign in Boost.Asio sockets, however I'm looking for something like release/unassign that would transfer the ownership on socket back to user. or some type of assign that would not transfer ownership to socket class, so it would not close it when destroyed. I'm aware of this solution but it involves d...

C++ destructor example

Hello My C++ is a little rusty but I have made a program that reverses a linked list and now I am trying to write the proper destructors for it but I don't know exactly what to destroy. Here are my class definitions: class LinkedList { private:ListElement *start; public:LinkedList(); public:void AddElement(int val); publ...

Callback for Button in QtCreator?

I just started using QtCreator tonight, and it seems it puts all of the interface stuff inside of the ui file. I followed a tutorial to create a resource for my icons, then I added them to a menu bar at the top. I need to make a connection when one of them is clicked though, and cannot figure out how to make a callback for it. Am I going...

Do we have design patterns in C++ as we have in java?

As we have so many design patterns in java, like wise do we have any in c++.Or can we use the same sort of patterns in c++. ...

Maya API to C++

Hi, I was reading about the Maya API to C++ and didn't quite understand the idea. Upon implementing the API, Can I create an environment, or a GUI in 3D world in Visual Studio? This question is related to my previous one about the Maya API. Question If someone could give me a good place to begin, it would be great. Thanks, Oded. ...

conversion operator as standalone function

Why does C++ require that user-defined conversion operator can only be non-static member? Why is it not allowed to use standalone functions as for other unary operators? Something like this: operator bool (const std::string& s) { return !s.empty(); } ...

Using std::streams to format output

I have an object that I want to be able to stream. But I want to be able to stream it in different ways by using different formats, or should I say ways to describe this object. And I wonder how this is supposed to be solved with streams. What I want is to be able to use a generic format and use some kind of format adapter to transform...