How can I find where a class is created in Eclipse CDT? - eclipse-cdt

Say I'm in a header file where a class is defined, and I want to know where this class is created/newed.
I know "Reference" gives you all places where class name appear. But what I want is more accurate: where this class is instantiated. Is Eclipse LUNA CDT smart enough to do this?

You go to your class header file and there you select a specific constructor of your class. Then you ask Eclipse to "Open Call Hierarchy" (usually through right-click menu). It will show you all the places where this specific constructor is called.

Related

Why did qt-creator fail to build after I named the widget class with a lower case letter?

I created a widget in the mainwindow and promoted it to my class, the widget was called "renderArea" and I named the class "renderArea" and got bugs. When I renamed the class to "RenderArea" it worked. Any idea why this would cause it to fail?
The designer (.ui) files are translated to headers (.h) by the "uic" compiler. In the resulting code there is an object variable with the same name of a class. This will produce compiler errors like the ones explained in this SO answer. You can't apply the same solution (adding the class keyword) to your scenario, because the code is auto-generated. But it works when you renamed the class starting with an upper-case, because the names are no longer the same (remember that C and C++ are case-sensitive).

Changing Class Variable Capitalization in Code::Blocks

SO I've been using Code::Blocks for awhile now, and I've experienced this annoying thing for quite awhile now. When you're creating a new class, it has the following setup page:
In the "Add new" section, we can, of course, add new variables and include "Getter" and "Setter" methods. So we add a few variables, and create a new class:
But here's where the problem occurs; when the getter and setter methods are added, they are named by default as "Getname" and "Setname." My question is: is there anyway to change it to be, by default "getName" and "setName?" (Note the change of capitalization). Or, on the other hand, should I be changing my coding style to match that of Code::Blocks? Thank you for your answers!
looks like this is done on purpose
http://wiki.codeblocks.org/index.php/Coding_style

How to automatically create virtual methods from inherited class in Qt Creator?

I am using QT4.8.4 + Qt Creator 2.8.1. Now I need to create several classes Child_X that inherit from another class Parent. In Parent I have several virtual methods.
Now I have to implement them in all of my Child_X classes. To save editing time, I'd like Qt do that for me automatically. When I remember right there is the possibility to have Qt create all the virtual methods. Does anybody know how?
Thank you
Sorry, I did not formulate correctly: I did not mean that Qt will automatically write the body of the methods. ( To invent that would probably make you very rich :-) )
I was talking about Qt writing all the headers of the virtual methods in the newly created (inherited) class. This saves a lot of writing/copying classnames etc.. The body would be empty in all the virtual methods.
Thank you
itelly
I hope you already found it, but maybe for others:
Right click on the class name in the editor.
In the menu, click on 'Refactor' and then on 'Insert virtual functions of base classes'.
You can choose to directly make the functions in the implementation file (as well as in the header file).
there is the possibility to have QT create all the virtual methods
There is no such possibility, because Qt can't read your mind and divine what those implementations are supposed to do.
Speaking of that - what are your virtual methods supposed to do? Please edit the question to fix that.

Why the class create by Qt creator has no destructor?

Every time I create a class, there is no destructor in the body of the class? Why is that? The Visual Studio will create a destructor automaticly but the Qt creator doesn't. Is there something special in the class of Qt?
In most well-designed C++ classes you don't need any custom code in the destructor and the default behavior is the right thing (i.e. destroying all members).
You can add a destructor if you want of course and please note that QtCreator mitigates the C++ annoyance of header/implementation duality by allowing automatic creation of the declaration from the implementation or vice versa (e.g. context menu -> refactor -> add public declaration).

inheritance in MS C++ using Visual Studio 2010

i have been going through the source code of an application which i downloaded from sourceforge.
i have a certain method which requires a pointer to an abstract class as a parameter.
class A;//abstract class
B::method(A *)
i cant create an object of A since its abstract.
so i can only pass pointer to object of child class of A in the B::method().
Now the problem is there are many classes in the source.
my problem is that how do i know which are the child classes of a parent class in visual studio 2010?
i have tried "find all references" for a virtual method of the abstract class (because its definition should be in the child class!) but without luck.
hope i could make my question clear!
Maybe "Solution Explorer" -> Your project -> Right Click Menu -> "Class Diagram" is what you're looking for ?
Another suggestion - try looking for " : public YourBaseClassName" strings and then "unwind" the inheritance. The usability certainly depends on the depth of your hierarchy. If there are multiple intermediate classes or multiple inheritance, then... Maybe, look at Eclipse+CDT ?