Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Halp Computer (stop all the list iterator)

Name: Anonymous 2009-03-22 2:50

Hey guys, harassing you for a simple reason: we're both pretty bored, I'm coding, and I hit a problem that google doesn't want to give its secrets for.
I'm making a game as a final project for this semester in C++, and I have a class "Actor" defined that is the root class for the "enemy", "sprite" and all other classes - essientially, it's a bitmap (i'm using Allegro) in an object with useful functions. I have a game engine which hold a list to pointers to all these objects, a list of Actors*. However, when I attempt to iterate through the list, on decleration of my iterator, g++ tells me,
"Engine.h:48: error: no match for call to '(std::list<Actor*, std::allocator<Actor*> >) (std::_List_iterator<Actor*>&)'
"
The line of code is "list<Actor*>::iterator pos = gameObjects.begin();"

So, any ideas?

Also, I am not a bbcode expert.

Name: Anonymous 2009-03-22 2:52

Also, gameObjects is declared as list<Actor*> gameObjects;, but I don't think that helps too much.

Name: Anonymous 2009-03-22 2:55

>>1
So, any ideas?
I have a couple.
1) Sepples is pig disgusting.
2) You are seriously retarded.

Name: Anonymous 2009-03-22 2:59

>>3
...thanks?

Name: Anonymous 2009-03-22 3:09

Throw me a freakin' bone here, guys, comon'.

Name: Anonymous 2009-03-22 3:20

>>5
Ask your professor you faggot. /prog/ is not for CS101 help.

Name: Anonymous 2009-03-22 3:25

>>6
Sweet. Then I get to hear,
"Dat is un compiler pwoblem. Uz das Vindows cumpiler, and ju vill be fine."
When was the last time you had a competent proffesor, dick?
If I'm so retarded, the answer's obvious - the answer that's not "C++ sucks dick"; that I've picked up on.

Name: Anonymous 2009-03-22 3:29

You're problem is that your lying about the code you used.  Post what it actually says.

Name: Anonymous 2009-03-22 3:35

//screen.h: definition of the game engine, which does all screen output
#pragma once
#include "Actor.h"
#include "fighter.h"
#include "bullet.h"
#include <iostream>
#include <allegro.h>
#include <cstring>
#include <loadpng.h>
#include <png.h>
#include <list>
#include <vector>
using namespace std;
class Actor; //solves a circular dependancy

class engine
{
public:
    engine(BITMAP* pages[2], BITMAP* offScreenTemp)
    {
        video_page[0]= pages[0];
        video_page[1]= pages[1];
        offscreen = offScreenTemp;
        offscreen_page = 0;
    }

    void drawToBuffer(BITMAP* sprite, int x, int y)
    {
        draw_trans_sprite(offscreen, sprite, x, y);
    }
   
    void flip_page(void)
    {
        // flip to the buffer
        show_video_bitmap(offscreen);

        // set the buffer to the other page
        offscreen = video_page[offscreen_page = 1 - offscreen_page];
    }
   
    void UpdateScreen()
    {
        flip_page();
        clear(offscreen);
        list<Actor*>::iterator pos = GameObjects.begin(); //fuck this line to HELL
        while(pos != GameObjects.end())
        {
            pos->update();
            pos++;
        }   
    }

    void AddActor(Actor* Newbie)
    {
        GameObjects.push_front(Newbie);       
    }
private:
int offscreen_page; // integer saying which is the offscreen page, 0 or 1.
BITMAP* video_page[2]; //the two pages the to draw pixels to
BITMAP* offscreen; //the current of-screen page to draw to.
list<Actor*> GameObjects;
};

Enjoy you're code.

Name: Anonymous 2009-03-22 3:35

>>7
When was the last time you had a competent proffesor
This semester.
If you meant when was the last time I had in incompetent professor. It was before I transferred to an ivy league university. Oddly enough- here they are all the worlds best in their field.

Name: Anonymous 2009-03-22 3:39

>>10
|worlds

Cool story bro.

Name: Anonymous 2009-03-22 3:44

>>11
Please, allow me to apologize for mistaking this as a place for informal discussion. I see now thanks to your expert guidance that this board is strictly formal and all English mistakes are punishable by having respondents conmpletely ignore anything else you said.

Name: Anonymous 2009-03-22 3:45

>>12
Dicks.

Name: Anonymous 2009-03-22 3:48

>>12
Please allow me to forgive your ignorance. It is not often someone completely misses the irony in saying they are educated, then making a simple grammatical mistake.

Oh wait, yr're a troll. Nevermind.

Name: Anonymous 2009-03-22 3:58

>>12
I like cocks.

Name: Anonymous 2009-03-22 4:05

Oh, so that's where the compiler error is!

Wait, you guys haven't told me yet.
Dicks.
I could become a regular /prog/go, posting meaningless memes and spouting garbage throughout your precious board.
Setting http://dis.4chan.org/read/prog as my home page in 3...2...

Name: Anonymous 2009-03-22 4:10

>>16
A fatal error occured! You didn't specify a thread to read.
Enjoy your new home page, faggot.

Name: Anonymous 2009-03-22 4:14

>>17
I could become a model poster, like this guy!

Name: Anonymous 2009-03-22 4:49

>>16
http://dis.4chan.org/abbc/ is a much better home page.

Name: Anonymous 2009-03-22 5:32

>>10
I DON'T NEED SCHOOL, I'VE GOT SICP!!!!!

Name: Anonymous 2009-03-22 7:23

You also forgot the [code] tags.
If you don't tell us it's code, how are we supposed to know?

Name: Anonymous 2009-03-22 8:50

The forward reference

class Actor; //solves a circular dependancy (sic)

comes after the inclusion of Actor.h -- was this intentional?

Putting this into VC++, clearing out the header files I don't have in favour of

class Actor {
public:
    void update();
};
class BITMAP;


I get

1>c:\users\######\documents\visual studio 2008\projects\dummy\cppscratch[spoiler]prog[/spoiler].cpp(44) : error C2839: invalid return type 'Actor **' for overloaded 'operator ->'
1>c:\users\######\documents\visual studio 2008\projects\dummy\cppscratch[spoiler]prog[/spoiler].cpp(44) : error C2039: 'update' : is not a member of 'std::list<_Ty>::_Iterator<_Secure_validation>'
1>        with
1>        [
1>            _Ty=Actor *
1>        ]
1>        and
1>        [
1>            _Secure_validation=true
1>        ]

referring to this line

            pos->update();

The first of which indicates a problem, maybe even the same one the gay g++ message is talking about.

Name: Anonymous 2009-03-22 9:48

pos is an iterator.
dereference it.

Name: Anonymous 2009-03-22 12:05

>>22
 It wasn't intentional; I have no other way that I know of including that class in that header file, and it is needed. That circular dependency was a bitch. Should it be before the inclusion? The site I got this tip from wasn't very clear. Moving it to before the inclusion doesn't do anything for the iterator problem.

As for the iterator mistakes, thank you for that, but my compiler doesn't even reach those before it says no, as it doesn't see the iterator being declared. The line where I say
[code]
list<Actor*>::iterator pos = GameObjects.begin(); //fuck this line to HELL
[code]
doesn't work, so naturally I don't get the iterator errors. I can take those lines out of my code, and still get the error at the above line. :/

Name: Anonymous 2009-03-22 12:11

(*pos)->update();

Name: Anonymous 2009-03-22 12:12

>>25 won't work when pos hasn't been declared yet

Name: Anonymous 2009-03-22 13:13

>>26
class Actor;

thread over

Name: Anonymous 2009-03-22 13:22

>>28
THEN WHO SOLVES CIRCULAR DEPENDANCY
Seriously, Actor needs engine, engine needs Actor, removing that line opens another can of worms.

Also, thread revived.

Name: Anonymous 2009-03-22 14:40

>>28


#ifndef _WHBT_
#define _WHBT_
/* Actor.h */
  class Engine; // forward declaration #1, you faggot

  class Actor {
  public:
    Actor();
    ~Actor();
    // ... rest of class definition here
  };
#endif

/* Actor.sepples */
  #include "engine.h"
  #include "actor.h"

  Actor::Actor() {}
  Actor::~Actor() {}
  // ... rest of method definitions here


/* Engine.h */
#ifndef _EXPONENTIALLY_
#define _EXPONENTIALLY_
  class Actor; // forward declaration #2

  class Engine {
    // class definition here
  }
#endif


/* Engine.sepples */
  // method definitions here

Name: Anonymous 2009-03-22 16:51

>>29
Why do stupid americans like you fall for these trolls so often

Name: sage 2009-03-22 17:08

>>29
Thanks a ton, you solved a problem that had four cocks up my ass. Saging own post.

Name: Anonymous 2009-03-22 17:23

>>30
>>29 is not American

Name: Anonymous 2009-03-22 18:29

>>32
Yeah, keep telling yourself that.

Name: Anonymous 2009-03-22 18:42

Please don't feed the World Vs. America trolls

Name: Anonymous 2009-03-22 20:06

Please don't feed the world

Name: Anonymous 2009-03-22 21:13

I am >>29 and I am Canadian not America

Name: Anonymous 2009-03-23 13:02

>> The line of code is "list<Actor*>::iterator pos = gameObjects.begin();"

Make your iterator part of the class declaration, obviously.  Put it in private sector, right under the list declaration.

I know this isn't constructive but this thread has taught me everyone on this board is fucking retarded, yes, including you OP.

Name: Anonymous 2009-03-23 14:01

>>36
This may surprise you but Canada is a country occupying most of northern North America.

Name: Anonymous 2009-03-23 15:04

>>37
Goddammit fronk, the thread's over. Your solution doesn't work, because your other assertion is correct - I am a retard, and the problem was the #includes, not that line. Doing what you suggest in the (now old) code fixes a small part of a far larger error. Now stop bumping this shit, you dick.

Name: Anonymous 2009-03-23 17:14

Goddammit fronk

Back to /b/, please.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List