User Profile

Collapse

Profile Sidebar

Collapse
raistlinx
raistlinx
Last Activity: Jul 23 '07, 03:06 PM
Joined: Jul 19 '07
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • raistlinx
    replied to Deconstructors
    in C
    I have solved the problem.
    See more | Go to post

    Leave a comment:


  • raistlinx
    started a topic Deconstructors
    in C

    Deconstructors

    When you create a template class, what do you do about deconstructors?

    Given the class below I added ~DLNode(){}; after the constructor, but when I ran some tests it didn't seem to ever fire when then main program ended.

    Can anyone shed some light on this?

    Code:
    template <class Type> 
    class DLNode{
    
    public:
    	DLNode(Type elem, DLNode* prev, DLNode* next){
    		data = elem;
    ...
    See more | Go to post

  • raistlinx
    replied to Question about variables
    in C
    Yeah. The thought that prompted the question was was imagining a huge class or series of classes where you have a mass of both pointers and variables and it gets hard to remember what is what.

    Is it safe to say that basic types are most often left as variables while objects are pointers or is that too often not the case?...
    See more | Go to post

    Leave a comment:


  • raistlinx
    replied to Question about variables
    in C
    This is good to know! :-)...
    See more | Go to post

    Leave a comment:


  • raistlinx
    replied to Question about variables
    in C
    I am actually asking about the node here, not the whole tree so let me take a different approach. In the class below is there any reason I should define 'element' as a pointer instead? (i.e. Type* element)

    In fact, what I am really trying to do is ask a general question about when to use a variable and when to use a pointer. I just gave an example to hopefully make the question clearer.

    Code:
    template <class Type>
    ...
    See more | Go to post

    Leave a comment:


  • raistlinx
    replied to Question about variables
    in C
    Sorry. Typo. What I meant was doubly-linked nodes, not a list.

    In any case, it was just an example and the question is about variables/pointers....
    See more | Go to post

    Leave a comment:


  • raistlinx
    started a topic Question about variables
    in C

    Question about variables

    Suppose I am creating a binary tree data structure using a double linked list. each node of the linked list will have an element and a pointer to two other nodes.

    In this instance my question is should I declare the element as a pointer like the pointers to the two other nodes or as a variable?

    My more general question is are there any conventions as to when to use a variable and when to use a pointer?

    ...
    See more | Go to post

  • raistlinx
    replied to Easy syntax question
    in C
    Thank you. What I was really looking for though was an explanation on the difference between something like int* a and int *a. Why is the '*' sometimes on the variable name and sometimes on the type?
    See more | Go to post

    Leave a comment:


  • raistlinx
    started a topic Easy syntax question
    in C

    Easy syntax question

    Is there a difference between

    void DLNode::setNext (DLNode* node){} or int* a

    and

    void DLNode<Type>::s etNext(DLNode *node){} or int *a


    I've seen both used, is it just a style thing or is there some difference?
    See more | Go to post

  • raistlinx
    replied to Trouble with Template classes
    in C
    Problem solved: DLNode<int> *intlist = new DLNode<int>(a);


    DOH...
    See more | Go to post

    Leave a comment:


  • raistlinx
    replied to Trouble with Template classes
    in C
    Ok, I did some more digging and it is not a problem with the templates it is a problem with the classes. I assume "first" has gone out of scope after the addNode method??? (note I took out the templates stuff for readability)


    Code:
    #include <stdio.h>
    #include "DLListint.h"
    
    main(){
    	DLListint intlist;
    	intlist.addNode(9);
    	printf("%d", intlist.getFirst());
    ...
    See more | Go to post

    Leave a comment:


  • raistlinx
    replied to Sequence
    in C
    A Sequence is an ADT that models, well a sequence of something. If you imagine a line of people holding hands you would have a "sequence" of people.

    If you further imagine the line grows from left to right then you can imagine two things. First, every person has a number which is how many places they are from the left (this is their rank). Second, everyone has someone (or the end of the sequence) to the left and to the right...
    See more | Go to post

    Leave a comment:


  • raistlinx
    replied to Trouble with Template classes
    in C
    Thanks for the help. I moved everything into the header file butnow I seem to have a problem accessing data. intlist.getFirs t() doesn't return the data. I first thought this was a problem with DLList accessing DLNode methods and tried adding it as a friend to DLNode but got the same results.

    Again, this must be something trivial?

    Code:
    #include <stdio.h>
    #include "DLList.h"
    
    main(){
    ...
    See more | Go to post

    Leave a comment:


  • raistlinx
    started a topic Trouble with Template classes
    in C

    Trouble with Template classes

    Hi. I'm trying to write series of classes using templates and am running into what must be a simple error. I'm a bit of a noob so I apologize in advance if this kind of question is not welcome here.

    When I try to run the program below i get the following error during build (using Visual Studio).

    Data Structures error LNK2019: unresolved external symbol "public: __thiscall DLNode<int>::DL Node<int>(int)"...
    See more | Go to post
No activity results to display
Show More
Working...