Announcement

Collapse
No announcement yet.

Trouble with "optional" parameters

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Trouble with "optional" parameters

    The following program will not compile.
    It issues error 480 - "Parameter mismatches definition"

    What did I do wrong?



    Code:
    ' Ex-07-03.bas
    ' Constructor with default parameters.
    
    #Compile Exe
    #Dim All
    
    #Include "Ex-07-01C.inc"
    
    Function PBMain () As Long
    
    	Local thiscube As Cube
    	Local defaultcube As Cube
    
    	Cube__Cube(thiscube,7,8,9)
    	Cube__Cube(defaultcube)
    	Print "volume = " + Str$(Cube__volume(thiscube))
    	Cube___Cube(thiscube)
    	WaitKey$
    
    End Function
    Code:
    ' ---------- a Cube class
    ' Ex-07-03.inc
    
    Macro CLASS=Type
    
    '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    CLASS Cube
    	m_lheight As Long
    	m_lwidth  As Long
    	m_ldepth As Long
    End CLASS
    
    '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    ' Constructor.
    Sub Cube__Cube(mycube As Cube, _
    					Optional ByVal lheight As Long, _
    					Optional ByVal lwidth As Long, _
    					Optional ByVal ldepth As Long)
    
    	 Print "Constructor"
    	 mycube.m_lheight = lheight
    	 mycube.m_lwidth  = lwidth
    	 mycube.m_ldepth  = ldepth
    
    End Sub
    
    '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    ' Destructor.
    Sub Cube___Cube(mycube As Cube)
    	 Print "Destructor"
    End Sub
    
    '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    ' Member function (compute volume).
    Function Cube__volume(mycube As Cube) As Long
    
    	 Print "Cube__volume"
    	 Function = mycube.m_lheight * mycube.m_lwidth * mycube.m_ldepth
    
    End Function
    
    '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Regards,
    Bob

  • #2
    ....

    Later: I compiled and all seems OK here, no compile errors: PBCC4.04
    Last edited by Eros Olmi; 26 Jul 2008, 05:49 PM.
    thinBasic programming language
    Win10 64bit - 8GB Ram - i7 M620 2.67GHz - NVIDIA Quadro FX1800M 1GB

    Comment


    • #3
      Thanks, Eros.

      I apparently compiled the wrong files.

      Regards,
      Bob

      Comment

      Working...
      X