qiuntus
qiuntus

Reputation: 38

Iterating over a list of custom classed objects

So I've looked up the issue and used the given solutions and came up with this piece of code:

list<Projectile*>::iterator bullet;
for(bullet = bullets.begin(); bullet != bullets.end(); bullet++)
    .
            .
            .               
}

Problem: No operator '=' matches these operands. The same with != ... I'm clueless as to why :/

Upvotes: 1

Views: 756

Answers (1)

Jerry Coffin
Jerry Coffin

Reputation: 490108

At least based on your comment, you're attempting to use a list<Projectile *>::iterator where a list<Projectile>::iterator is needed.

As an aside, 1) list is rarely the best choice of containers, and 2) most of the time, you're better off iterating through a collection with a pre-packaged algorithm instead of writing a loop.

Upvotes: 3

Related Questions