Page 1 of 3 123 LastLast
Results 1 to 10 of 25

Thread: C++ Help needed

  1. #1
    Member RogerWilco's Avatar
    Join Date
    Mar 2012
    Location
    $home
    Posts
    152
    Points
    656
         User Info     Contact     Gamer ID
    Join Date
    Mar 2012
    Location
    $home
    Posts
    152
    Points
    656

    Post C++ Help needed

    I posted this on game dev threads, and also c++, I'm pretty intermediate with c++, I've only used it for work everyday for 10+ years, so I was shocked when the following code didn't work, and the reason its not working still eludes me, I figured I moght as well post it here too.

    //extraneous code removed
    ALLEGRO_FONT* RESOURCEMANAGER::GetFont(const string filename)
    {
    return fonts[filename];
    }

    fonts is an stl::map defined as follows:

    private stl::map<const char*, ALLEGRO_FONT*, ltstr> fonts;

    When the function GetFont is called, the debugger shows the RESOURCEMANAGER, a singleton, as being null, but a breakpoint in the resourcemanager's constructor shows fonts contains a pointer to all fonts loaded in said constructor, very puzzling to me.

    Its probably something stupid I overlooked, probably overtired at this point.

    0 Not allowed! Not allowed!
    Last edited by RogerWilco; 03-23-2012 at 12:26 PM. Reason: I had filename in quotes when i typed the post

  2. #2
    Bot Bot's Avatar
    Join Date
    Aug 2011
    Posts
    2,671
    Points
    7,720
         User Info     Contact     Gamer ID
    Join Date
    Aug 2011
    Posts
    2,671
    Points
    7,720

    Default

    Line 2: error: expected constructor, destructor, or type conversion before '*' token
    compilation terminated due to -Wfatal-errors.

    0 Not allowed! Not allowed!








  3. #3
    Member RogerWilco's Avatar
    Join Date
    Mar 2012
    Location
    $home
    Posts
    152
    Points
    656
         User Info     Contact     Gamer ID
    Join Date
    Mar 2012
    Location
    $home
    Posts
    152
    Points
    656

    Default

    I'm not sure what your trying to compile... that's not compilable code

    0 Not allowed! Not allowed!

  4. #4
    Robot Universe Owner
    Creator of DarkFrost
    demon450's Avatar
    Join Date
    Apr 2010
    Location
    New York
    Posts
    2,697
    Points
    6,184
         User Info     Contact     Gamer ID
    Join Date
    Apr 2010
    Location
    New York
    Posts
    2,697
    Points
    6,184
    Gamer IDs

    Gamertag: Medius450 PSN ID: Medius1337

    Contact info:

    Youtube Channel: http://www.youtube.com/user/Roceso1337

    Default

    Quote Originally Posted by RogerWilco View Post
    I'm not sure what your trying to compile... that's not compilable code
    maybe its the part thats broken?

    and also may you please display all the compile errors here exactly how they are

    0 Not allowed! Not allowed!
    Check out Darkfrost
    Check out Robot Universe






  5. #5
    Member RogerWilco's Avatar
    Join Date
    Mar 2012
    Location
    $home
    Posts
    152
    Points
    656
         User Info     Contact     Gamer ID
    Join Date
    Mar 2012
    Location
    $home
    Posts
    152
    Points
    656

    Default

    Quote Originally Posted by demon450 View Post
    maybe its the part thats broken?

    and also may you please display all the compile errors here exactly how they are
    There are no compiler errors, these are runtime errors, hence the mentioning of a debugger and breakpoints... the debugger and breakpoints don't happen if you get compiler errors.

    My post clearly states what the problem is, ResourceManager is empty, meaning whatever is being returned by that pointer is no good. The question is why is it no good?

    0 Not allowed! Not allowed!

  6. #6
    Robot Universe Owner
    Creator of DarkFrost
    demon450's Avatar
    Join Date
    Apr 2010
    Location
    New York
    Posts
    2,697
    Points
    6,184
         User Info     Contact     Gamer ID
    Join Date
    Apr 2010
    Location
    New York
    Posts
    2,697
    Points
    6,184
    Gamer IDs

    Gamertag: Medius450 PSN ID: Medius1337

    Contact info:

    Youtube Channel: http://www.youtube.com/user/Roceso1337

    Default

    oic i skimmed for errors
    every time u store something put it in a message box

    0 Not allowed! Not allowed!
    Check out Darkfrost
    Check out Robot Universe






  7. #7
    Member RogerWilco's Avatar
    Join Date
    Mar 2012
    Location
    $home
    Posts
    152
    Points
    656
         User Info     Contact     Gamer ID
    Join Date
    Mar 2012
    Location
    $home
    Posts
    152
    Points
    656

    Default

    Quote Originally Posted by demon450 View Post
    oic i skimmed for errors
    every time u store something put it in a message box
    Store what now?

    0 Not allowed! Not allowed!

  8. #8
    Robot Universe Owner
    Creator of DarkFrost
    demon450's Avatar
    Join Date
    Apr 2010
    Location
    New York
    Posts
    2,697
    Points
    6,184
         User Info     Contact     Gamer ID
    Join Date
    Apr 2010
    Location
    New York
    Posts
    2,697
    Points
    6,184
    Gamer IDs

    Gamertag: Medius450 PSN ID: Medius1337

    Contact info:

    Youtube Channel: http://www.youtube.com/user/Roceso1337

    Default

    Quote Originally Posted by RogerWilco View Post
    Store what now?
    wats at the address of the pointers

    0 Not allowed! Not allowed!
    Check out Darkfrost
    Check out Robot Universe






  9. #9
    Member RogerWilco's Avatar
    Join Date
    Mar 2012
    Location
    $home
    Posts
    152
    Points
    656
         User Info     Contact     Gamer ID
    Join Date
    Mar 2012
    Location
    $home
    Posts
    152
    Points
    656

    Default

    uhm... data? lol

    Okay, here's the problem, something with the way I passed the pointer, it probably should have been passes as a reference to a pointer, like &*

    I'm not sure if you are referring to a putting a message box in the post so you can read it better, or you are telling me to have a message box pop up with the contents of the memory address.

    If its the second one, which I think is what you mean, I have a debugger running, meaning when I insert a breakpoint I can see the whole data structure, in fact I can see the whole program in memory.

    Now that said the problem is this instance is returning NULL! empty! nada! zip! zilch! 0! etc.

    Yet the data exists, its like the pointer is returning a completely separate instance. the pointer points to 0x00000, and I cant figure out why. I am trying a new way of doing things, I have a way that works, I was just experimenting. I don't think I should have even posted this here, I don't think we all have the same definition of "coder"

    0 Not allowed! Not allowed!

  10. #10
    Banned
    Join Date
    May 2011
    Location
    ');DROP TABLE 'users';--
    Posts
    737
    Points
    1,710
         User Info     Contact     Gamer ID
    Join Date
    May 2011
    Location
    ');DROP TABLE 'users';--
    Posts
    737
    Points
    1,710

    Default

    In allegro font is stored as pointer so try returning the reference

    0 Not allowed! Not allowed!
    Last edited by Nity; 03-23-2012 at 12:23 PM.

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -10. The time now is 06:09 AM.
Powered by vBulletin®
Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.