NULL in comparison

Apr 17, 2013 at 5:10am
In my code below, assuming l was either initially created or was initially NULL,
1
2
3
4
5
6
7
  void createList(LinkedList* l){
    delete l;
    cout<<"\nWhat will you name the new list?\n";
    std::string n;
    cin>>n;
    l = new LinkedList(n);
}

\if I were to do the comparison l==null shouldnt this yield false following this code bit? Because its coming up true, and I'm not entirely sure why. Any eyeopening words would be most appreciated.
Apr 17, 2013 at 7:02am
1
2
3
//void createList(LinkedList* l){ // 'l' is passed by value; the function operates on a local copy

void createList( LinkedList*& l ){ // instead, pass 'l' by reference 
Topic archived. No new replies allowed.