[quote name='dimitri.adamou' timestamp='1344803877' post='4968820']
I'm pretty sure with any modern day compiler, your able to stop the execution of code at your desired lines. So start from the top of the stack,
I have a feeling your are slicing, you could try declare your setX and setY as virtual (in the inheritted classes) - or it could be possible that you've casted an object that doesn't even have the setX/setY
As you are calling a Pointer to Item, if you wish to have Polymorphic functionality you need to declare virtual on the desired functions eg
in weapon.cpp
void Weapon::setX(int x)
{
box.x = x;
}
is now
virtual void Weapon::setX(int x)
{
box.x = x;
}
I'm not sure what object Item* is supposed to represent, I've gone through your code briefly but I have not compiled it
I actually doesn't really know how to debug roperly. I've learned myself to use Watches and Call-stack aswell as breakpoints. And as i said in my first post "This code is where it crashes: "content->setX(contBox.x);". If i comment that out it will instead crash on the render function. The reason is that the pointer is no longer (Currency*) but (class Item*) in the "watches window".".
Whilst googeling around on the problem i was having i say some post about slicing. I don't really know what it is thought. Might have to read into that.
Why would i make them virtual in the inheritted classes? What would that change, i only thought you made them virtual in interfaces.
Item* is an interface all the items will be using in the game. At the moment there are only "Weapon", "Armor" and the broken "Currency". this is my first project ever so i'm pretty sure i'll have to rewrite my code from the start at some point, even now i see how much worse i was at coding when i look at the little older code in my project.
[/quote]
Oops. My bad, I went through your code and saw that in item.h virtual is defined.. but it is derived from yet another class.
Your classes are trying to do too much, the design is a bit confusing - you should try seperate everything as much as possible. Someone wrote a really good article on gdev.net, but I can't seem to find it.. it spoke about foward declaration and just maintaining neatness in code
As for slicing here is a simple quick example
class firstclass
{
public:
void hello() { cout << "firstclass::hello();" << endl; }
}
class secondclass : public firstclass
{
public:
int valA;
void hello() { cout << "secondclass::hello();" << endl; }
}
firstclass A;
secondclass B;
A = B; //slicing occurs. valA has no access
A.hello(); // firstclass::hello(); gets printed out
Thats slicing at its bare-basics, but with pointers and virtual tables this can get resolved (after looking a bit deeper in your code that doesn't appear to be the problem)
I haven't spent much time in there though. But yeah, back to my original point - your classes are trying to do too much