Jump to content

  • Log In with Google      Sign In   
  • Create Account


Why are my two classes sharing variables? C++


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
25 replies to this topic

#21 Squared'D   Members   -  Reputation: 2233

Like
2Likes
Like

Posted 31 March 2014 - 12:27 AM

I think i found out the bug today guys. Basically what happened was that i declared an array of octorocks:
OCTOROCK octorocks[4];
But what i did wrong was that initialized it like this
octorock[1].x =......
octorock[2].x =......
octorock[3].x =......
octorock[4].x =......
What i did wrong is that i didnt access octorock[0] and did a memory violation by going out of bounds in tbe array with octorock[4].


Don't worry. Mistakes like this are quite common. That's why I tend to look to see if I've made silly mistakes first when debugging. I hate it when I end up making major changes when the original bug just turns out to be a missing minus or something. Glad you found the answer.

Learn all about my current projects and watch some of the game development videos that I've made.

Squared Programming Home

New Personal Journal

 


Sponsor:

#22 Waaayoff   Members   -  Reputation: 781

Like
0Likes
Like

Posted 31 March 2014 - 01:03 AM

 

 

Just curious. You set a lot of class variables as private. Any reason why you do that?

 

wat  

 

In a simple answer, data hiding. It is usually common practice to make class members (variables) private and only allow access by way of constructors(mainly for initializing the class object) and class methods (functions). 

 

 

Yes.. Except he's asking why they are private, not public. I guess it was a typo.


"Spending your life waiting for the messiah to come save the world is like waiting around for the straight piece to come in Tetris...even if it comes, by that time you've accumulated a mountain of shit so high that you're fucked no matter what you do. "

#23 BHXSpecter   Members   -  Reputation: 1462

Like
0Likes
Like

Posted 31 March 2014 - 06:21 PM

My apologies. Meant to quote just Buckeye and didn't realize I had quoted your post. It wasn't aimed at you. Again, I'm sorry, I should have paid closer attention to what I was quoting before submitting it.


"Through vengence I was born.Through war I was trained.Through love I was found. Through death I was released. Through release I was given a purpose."


#24 dejaime   Crossbones+   -  Reputation: 4003

Like
0Likes
Like

Posted 01 April 2014 - 11:16 AM

I think i found out the bug today guys. Basically what happened was that i declared an array of octorocks:
[...]
What i did wrong is that i didnt access octorock[0] and did a memory violation by going out of bounds in tbe array with octorock[4].

So it was indeed bad pointer management!
These kind of symptoms are really common in these cases.

#25 ISDCaptain01   Members   -  Reputation: 1380

Like
0Likes
Like

Posted 07 April 2014 - 03:50 PM

Thought Id show everybody how it looks now:

 

https://www.youtube.com/watch?v=cYd_ZtfNgWk

 

The final version will be posted in the announcements section once I complete it, so stay tuned!



#26 BHXSpecter   Members   -  Reputation: 1462

Like
0Likes
Like

Posted 07 April 2014 - 05:31 PM

Looking good ISDCaptain01. I'll keep a look out on the announcements section for sure.


"Through vengence I was born.Through war I was trained.Through love I was found. Through death I was released. Through release I was given a purpose."





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS