munin
+ Reply to Thread
Results 1 to 2 of 2

Thread: Need help in c++ code

  1. #1
    Join Date
    Mar 2008
    Posts
    1

    Question Need help in c++ code

    Hello everyone,
    I am new member, and I had problem
    I wrote a code which needed a kdtree data structure for nearest neighbour algorithm, so I found a code written in c++, but in there I found " this " variable which I haven't seen like it before and I don't know what does it mean as well. Simply the code is a lass that have find parent function like that:

    KDTEMPLATE
    KDNODE* KDNODE::FindParent(Xtype* x0)
    {
    KDNODE* parent ;
    KDNODE* next = this ;
    int split ;
    while(next)
    {
    split = next->axis ;
    parent = next ;
    if(x0[split] > next->x[split])
    next = next->Right ;
    else
    next = next->Left ;
    }
    return parent ;
    }

    so if any one know what " this " means please tell me or may be you know where can I find a c++ documentations that illustrates it .

    Thank in advance for any kind of help

  2. #2
    Join Date
    Sep 2005
    Posts
    2,050
    In C++ OOP, 'this' is used in a member function as a pointer to the object that was used to call the function.

    In the case of your code, the object would be of KKDTEMPLATE KDNODE* type [I think], and the member function is FindParent(Xtype* x0).
    Who needs drugs when you have electrons?

+ Reply to Thread

Similar Threads

  1. code help
    By drumgodmaggott in forum Programming
    Replies: 5
    Last Post: 04-05-2009, 10:54 PM
  2. Source code
    By mlg solidsnake in forum Tutorials
    Replies: 18
    Last Post: 04-30-2007, 12:08 PM
  3. How do you code & hide?
    By Tito in forum Tutorials
    Replies: 2
    Last Post: 04-27-2007, 05:19 PM
  4. converting hex code
    By dannyyy in forum Security & Encryption
    Replies: 1
    Last Post: 03-19-2007, 12:40 PM
  5. need HTML code
    By novice_shail in forum Internet Privacy
    Replies: 1
    Last Post: 11-05-2005, 03:41 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts