Search Results

Search found 3 results on 1 pages for 'kyeana'.

Page 1/1 | 1 

  • learning C++ from java, trying to make a linked list.

    - by kyeana
    I just started learning c++ (coming from java) and am having some serious problems with doing anything :P Currently, i am attempting to make a linked list, but must be doing something stupid cause i keep getting "void value not ignored as it ought to be" compile errors (i have it marked where it is throwing it bellow). If anyone could help me with what im doing wrong, i would be very grateful :) Also, I am not used to having the choice of passing by reference, address, or value, and memory management in general (currently i have all my nodes and the data declared on the heap). If anyone has any general advice for me, i also wouldn't complain :P Key code from LinkedListNode.cpp LinkedListNode::LinkedListNode() { //set next and prev to null pData=0; //data needs to be a pointer so we can set it to null for //for the tail and head. pNext=0; pPrev=0; } /* * Sets the 'next' pointer to the memory address of the inputed reference. */ void LinkedListNode::SetNext(LinkedListNode& _next) { pNext=&_next; } /* * Sets the 'prev' pointer to the memory address of the inputed reference. */ void LinkedListNode::SetPrev(LinkedListNode& _prev) { pPrev=&_prev; } //rest of class Key code from LinkedList.cpp #include "LinkedList.h" LinkedList::LinkedList() { // Set head and tail of linked list. pHead = new LinkedListNode(); pTail = new LinkedListNode(); /* * THIS IS WHERE THE ERRORS ARE. */ *pHead->SetNext(*pTail); *pTail->SetPrev(*pHead); } //rest of class

    Read the article

  • Interrupting a thread from inside a runnable class? (java)

    - by kyeana
    I am trying to set up a method inside a class that implements the runnable interface that will set the interrupt status of that class. The reason i want to be able to do it from inside the class is there is some other clean up stuff that i need to take care of as well, and i would like to be able to do it all by calling one method instead of calling, for example: Gui gui = new Gui() // class that implements runnable Thread guiThread = new Thread(gui, "gui thread"); guiThread.start() ... ... guiThread.interrupt(); gui.cancel(); Currently my cancel code looks like this, however it isn't correctly setting the interrupt status of this thread. public void cancel() { Thread.currentThread().interrupt(); // other clean up code here. } Any advice on if/how i could get this working? Thanks. EDIT: I when i tried to get the cancel working, i commented out the guiThread.interrupt(), so that i wasn't just setting the status the reseting the status.

    Read the article

  • Another C++ question, delete not working?

    - by kyeana
    New to c++, and am having a problem with delete and destructor (I am sure i am making a stupid mistake here, but haven't been able to figure it out as of yet). When i step through into the destructor, and attepmt to call delete on a pointer, the message shows up "Cannot access memory at address some address." The relevant code is: /* * Removes the front item of the linked list and returns the value stored * in that node. * * TODO - Throws an exception if the list is empty */ std::string LinkedList::RemoveFront() { LinkedListNode *n = pHead->GetNext(); // the node we are removing std::string rtnData = n->GetData(); // the data to return // un-hook the node from the linked list pHead->SetNext(n->GetNext()); n->GetNext()->SetPrev(pHead); // delete the node delete n; n=0; size--; return rtnData; } and /* * Destructor for a linked node. * * Deletes all the dynamically allocated memory, and sets those pointers to 0. */ LinkedListNode::~LinkedListNode() { delete pNext; // This is where the error pops up delete pPrev; pNext=0; pPrev=0; }

    Read the article

1