Hello Guest, please login or register.
Did you miss your activation email?
Login with username, password and session length.

Pages: [1]   Go Down

Author Topic: Need some help with my C++ Project.  (Read 1545 times)

0 Members and 1 Guest are viewing this topic.
Need some help with my C++ Project.
« on: March 25, 2009, 10:57:12 pm »
  • *
  • Reputation: +2/-0
  • Offline Offline
  • Gender: Male
  • Posts: 1767
Yeah I'm kinda at a loss on what to do. I'm having trouble trying to figure out where exactly I should check to see if a node with the same ID exists or not. I don't know whether to just do it in the insert_node function or in the read_dailylog function. I think it'd be easier to just do it in insert_node though. Then that's where I run into problem two. I'm not exactly sure on HOW I should check it. I think I may have screwed myself over while initially coding this. I'm probably just over thinking it though. <_<

Any suggestions? Source code attached.
Logged
  • https://colbydude.com
Re: Need some help with my C++ Project.
« Reply #1 on: March 25, 2009, 11:30:24 pm »
  • Doesn't afraid of anything
  • *
  • Reputation: +42/-0
  • Offline Offline
  • Gender: Male
  • Posts: 7002
As far as how to check goes, you can do something like this:

Code: [Select]
bool check(plumb_part checker)
{
   for ( plumb_part current = firstNode; current != NULL; current = current.next)
   {
     if (checker.ID = current.ID)
     {
         return true;
     }
   }
    return false;
}

I havent really gone through your code much yet, but this seems like a general way to do it.

EDIT:  Sorry, post went through before I finished typing it >_>  There's the full.
« Last Edit: March 25, 2009, 11:34:13 pm by MG-Zero »
Logged



i love big weenies and i cannot lie
Re: Need some help with my C++ Project.
« Reply #2 on: March 25, 2009, 11:37:04 pm »
  • *
  • Reputation: +2/-0
  • Offline Offline
  • Gender: Male
  • Posts: 1767
Oh wow, can't believe I didn't think of a function to return true or false...  I'll test it here in a sec and let you know how it goes.
Logged
  • https://colbydude.com
Re: Need some help with my C++ Project.
« Reply #3 on: March 26, 2009, 12:30:00 am »
  • *
  • Reputation: +2/-0
  • Offline Offline
  • Gender: Male
  • Posts: 1767
No dice. Tried several different times but I'm not havin any luck with it for some reason. The check function doesn't seem to be working, I think I have something jacked up in my code that's making it always return true.

Attached is the updated cpp file.
Logged
  • https://colbydude.com
Re: Need some help with my C++ Project.
« Reply #4 on: March 26, 2009, 12:46:54 am »
  • *
  • Reputation: +9/-0
  • Offline Offline
  • Posts: 728
Code: [Select]
bool check(plumb_part checker)
{
   for ( plumb_part current = firstNode; current != NULL; current = current.next)
   {
     if (checker.ID = current.ID)
     {
         return true;
     }
   }
    return false;
}

I think he meant:

Code: [Select]
if (checker.ID == current.ID)
{
    return true;
}

Haven't messed with c++ in awhile, but I think the "==" is necessary for comparisons.
Logged
  • Pyxosoft
Re: Need some help with my C++ Project.
« Reply #5 on: March 26, 2009, 12:57:37 am »
  • *
  • Reputation: +2/-0
  • Offline Offline
  • Gender: Male
  • Posts: 1767
Oh wow again. Can't believe I completely overlooked that. >_> That fixed it up. My deletes are a little wonky now, but I can take care of that. Thanks guys.
Logged
  • https://colbydude.com
Re: Need some help with my C++ Project.
« Reply #6 on: March 26, 2009, 03:05:56 am »
  • Doesn't afraid of anything
  • *
  • Reputation: +42/-0
  • Offline Offline
  • Gender: Male
  • Posts: 7002
Yes, thank you for catching that error.
Logged



i love big weenies and i cannot lie
Pages: [1]   Go Up

 


Contact Us | Legal | Advertise Here
2013 © ZFGC, All Rights Reserved



Page created in 0.237 seconds with 51 queries.