Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Suspicious pointer assignment
#1
Code:
TYPE two3tree
  root as two3node ptr
  size as integer
  depth as integer
  AddNode as Sub(value as integer)
END TYPE

SUB AddNode(value as integer)
  If this.root = 0 then
    this.root = NewTwo3Node(value)
  else
    dim p as Two3Node ptr
    p = this.root
  end if
  this.size = this.size + 1
END SUB

NewTwo3Node returns a Two3Node ptr but that like gives me an Implicit conversion warning and p = this.root gives me the suspicious pointer assignement warning. What's going on?
f you play a Microsoft CD backwards you can hear demonic voices. The scary part is that if you play it forwards it installs Windows.
Reply
#2
Is this a global variable? Looks like it should be a parameter. ie., there is no implicit this, reference or pointer. You'll have to pass the address - or reference - of an 'object' to it's 'member functions' manually.
stylin:
Reply
#3
Yeah, function pointers are the same as in C - not member functions of classes. Make sure you use Option Explicit to catch undeclared variables.
Reply
#4
O, I thought this worked the same was as it did in C++. There is no way to access a subs invoking data type from within the sub?

ie:
Code:
DIM temp as two3tree
temp = NewTwo3Tree
temp.AddNode(6)

There is no way to access temp from inside the AddNode sub without passing having it be a parameter?
f you play a Microsoft CD backwards you can hear demonic voices. The scary part is that if you play it forwards it installs Windows.
Reply
#5
Correct, it must be a parameter. hopefully fb will move rapidly towards a move to a gcc frontend, which will give us oop and lead basic users once and for all into the promised land...


er.. sorry i got carried away there :o
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)