Todd wrote:
How would I implement GetComponent such that it returns a COPY of the underlying myComponent from the compList? After examining the source code for nsLocalFile, I thought I could do the following (I've omitted some error checking to make the example simpler), but it won't compile:
The usual way is to add a clone() method to the interface. The implementation of that has access to the concrete class and thus has no problems using the copy constructor to make a copy. (This is what nsILocalFile does).
You can cast the value in an nsCOMPtr to to a concrete class, but you need to be sure that the type stored in it is what you expect to be...
Note that another way would be to use nsRefPtr<myComponent> as the type of your array elements instead of nsCOMPtr<myIComponent>, since that would also ensure that you have access to the concrete type.
-- All the world's a stage, And all the men and women merely players: They have their exits and their entrances; And one man in his time plays many parts, [...] --W. Shakespeare _______________________________________________ dev-tech-xpcom mailing list [email protected] https://lists.mozilla.org/listinfo/dev-tech-xpcom
