Skip to content

Private Access Control

Paul Squires edited this page Sep 19, 2026 · 1 revision

Home › User Defined Types › Private: (Access Control)

Private: (Access Control)

Specifies private member access control in a Type or Class

Syntax

Type typename
Private:
member declarations
End Type

Parameters

  • typename
  • member declarations

Description

Private: indicates that member declarations following it have private access.
Private members are accessible only from inside a member procedure of their Type or Class. Seen from inside such a member procedure, it is as if the protected member is in fact public, and that regardless of the object on which the access operator is applied.

member declarations following Private: are private until a different access control specifier is given, like Public: or Protected:.

Members in a Type declaration are Public: by default if no member access control specifier is given.

Remarks

Dialect Differences

  • Available only in the -lang fb dialect.

Differences from QB

  • New to FreeBASIC

See also

Examples

Type testing

  number As Integer

  Private:

    nome As String

  Declare Sub setNome( ByRef newnome As String )

End Type

Sub testing.setnome( ByRef newnome As String )

  '' This is OK. We're inside a member function for the type

  this.nome = newnome

End Sub

Dim As testing myVariable

'' This is OK, number is public

myVariable.number = 69

'' this would generate a compile error

'' - nome is private and we're trying to access it outside any of this TYPE's member functions

'' myVariable.nome = "FreeBASIC"

Category: User Defined Types
Kind: type


Reproduced from the FreeBASIC Wiki Manual under the GNU Free Documentation License 1.3 — with no Invariant Sections, no Front-Cover Texts and no Back-Cover Texts. Copyright © the FreeBASIC project and wiki contributors. See License.

Clone this wiki locally