Sign in to follow this  

how to find variable definition that specific class?

This topic is 4200 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have no idea what you're trying to say. You want to find something? What do you mean find? Something like:
typedef find<a,b,d>::type t;

Where t will be the first type found? Do you want to add all objects of a specific class to an array? The code you posted doesn't seem to have anything to do with finding the class, as long as A is already declared there should be no problem.

Share this post


Link to post
Share on other sites
Change:
class A { ... };

to
class A_doesnt_exist { ... };

and recompile your entire project. Every time someone refers to class A, it will result in an error. :)

It also generates more error spam.

Alternatively, you can add a non-implemented virtual function to A:
class A { ...
virtual void not_implemented() = 0;
};

then any time anyone instantiates an instance of class A, there will be a compiler error.

Or, you can use your IDE's tools to find your copies of A. :)

This won't find A* pointer; but it will find pointer = new A();

Share this post


Link to post
Share on other sites
Quote:
Original post by Dave Hunt
Go to the original definition of class A, right click, and select find all references. (Assuming VS2005)


Not foolproof, unfortunately:

struct A {};

template<bool b>
struct Foo
{
typedef A type;
};

template<>
struct Foo<false>
{
typedef int type;
};

typedef A B;

int main()
{
A a;
B b;
Foo<true>::type c;
Foo<false>::type d;
}



Will only find a, as far as actual instances are concerned. It will find the typedefs, but not the instances using them. As NotAYakk hints, only by compiling the program can you actually find them all.

[Edited by - Fruny on June 13, 2006 10:18:26 PM]

Share this post


Link to post
Share on other sites

This topic is 4200 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this