# How can i remove this class, whats the problem?

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

## Recommended Posts

(all the code and classes are my own, which makes this question look more stupid) http://nopaste.com/p/aP1gFCFtm if you look at main.cpp you'll see the class CSubTreeIterator_STL it looks like i can do without that class. I tried removing it but i get compile errors. It has something to do with conversion but i dont know why or how the extra class fixed that conversion. -Edit- No errors in this paste. When i try to remove that class there are errors [Edited by - EccentricSight on May 6, 2008 2:22:11 PM]

##### Share on other sites
Post the exact errors and the lines that cause them (not just line numbers, the actual lines).

##### Share on other sites
I don't see your main() function in what you call "main.cpp". Where does all this stuff get used?

##### Share on other sites
There is a lot of source that goes with this. I removed except for what is needed to compile. There is no need for the rest of the source. The paste compiles and what i want to know is how can i remove the CSubTreeIterator_STL class without getting compile errors.

##### Share on other sites
post the actual compiler errors. my brain can't compile your code

-me

##### Share on other sites
Ok. It's easy:

Since none of the code is ever used, none of it needs to be there.

##### Share on other sites
:| I cant believe people want more code AND compile errors along with the job of cleaning code instead of just cleaning code. Ok, here you go. the source http://nopaste.com/p/aMPorJBFp

the error (its on the line with return &subIt; )

error C2440: 'return' : cannot convert from 'CSTLfiterator<_t,_t2,_t3> *__w64 ' to 'Cfiterator<_t> *'        with        [            _t=std::vector<CDirItems *>,            _t2=std::_Vector_const_iterator<CDirItems *,std::allocator<CDirItems *>>,            _t3=CDirItems *        ]        and        [            _t=CTreeFIterator<const char *> *        ]        Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

enjoy ;P

##### Share on other sites
It means exactly what it says. After making the changes to your code implied by the comments, subIt is a member of type CSTLfiterator<vector<CDirItems*>, vector<CDirItems*>::const_iterator, CDirItems*>. According to the class definition, that inherits from Cfiterator<CDirItems*>. Yet, you're trying to return its address from a method whose return value is the address of a Cfiterator<CTreeFIterator<const char *> *>, which is a completely different type. So maybe you need to clarify what you're trying to do here.

##### Share on other sites
>So maybe you need to clarify what you're trying to do here.

Thats exactly why i didnt want to post the bug. People will think i am trying to solve it and not read my question

>According to the class definition, that inherits from Cfiterator<CDirItems*>. Yet, you're trying to return its address from a method whose return value is the address of a Cfiterator<CTreeFIterator<const char *> *>

CDirItems inherits CTreeFIterator<const char *>. So both of these are or should be Cfiterator<CTreeFIterator<const char *> *>.

If you look at the first paste you'll see that CSubTreeIterator_STL does nothing with itData. So i should be able to skip the class entirely (look at it, it does nothing) but i get that error instead. Why?
---------------------------------------------

For guys who are reading this part.
This is the first paste where everything works correctly http://nopaste.com/p/aP1gFCFtm
I want to remove class CSubTreeIterator_STL, guys kept bugging me for an error so i made this paste http://nopaste.com/p/aMPorJBFp . It seems like it doesnt like to mix Cfiterator<CDirItems*> and Cfiterator<CTreeFIterator<const char *> *> which both are Cfiterator<CTreeFIterator<const char *> *> . Now iam trying to understand why it works when i have the CSubTreeIterator_STL which does nothing and does not work w/o that class.

##### Share on other sites
Quote:
 Original post by EccentricSightCDirItems inherits CTreeFIterator. So both of these are or should be Cfiterator *>.

Nope, sorry. It isn't. That's your problem. Templates don't work that way. A Cfiterator over derived is not a kind of Cfiterator over base. In general, X<B> and X<D> have nothing to do with each other, inheritance-wise, even if D is derived from B. The missing class is, apparently (although I'm too busy with other stuff right now to grok it fully) a wrapper which causes this relationship to exist.

1. 1
2. 2
Rutin
19
3. 3
4. 4
5. 5

• 15
• 13
• 9
• 12
• 10
• ### Forum Statistics

• Total Topics
631442
• Total Posts
3000089
×