Search found 9496 matches

by fxm
Apr 01, 2020 19:24
Forum: Beginners
Topic: (SOLVED) The extra destructor is called
Replies: 13
Views: 312

Re: The extra destructor is called

Because 'Return r' (when returning by value) always calls the copy-constructor, but it is implicit in this case (defined/added code by the compiler). See here with an explicit copy-constructor: Type rational numerator As Integer denominator As Integer Declare Constructor() Declare Constructo...
by fxm
Mar 29, 2020 13:01
Forum: General
Topic: OOP test
Replies: 13
Views: 320

Re: OOP test

error 188: Missing UDT.constructor(byref as const UDT) implementation ( base UDT without default constructor requires manual initialization), found 'end' in 'end type' Define a 'constructor TAnimal ()' : constructor TAnimal () end constructor And also: constructor TMammel( l as strin...
by fxm
Mar 29, 2020 11:38
Forum: General
Topic: OOP test
Replies: 13
Views: 320

Re: OOP test

Where is the body of the member procedure 'TAnimal.getName() as string'?
by fxm
Mar 26, 2020 22:42
Forum: General
Topic: Ask about "new" and "delete"
Replies: 5
Views: 182

Re: Ask about "new" and "delete"

Just an important note about your code: - 'NEW' must be finished with a 'DELETE' . - 'NEW []' must be finished with a 'DELETE []' . So the correct code line is : 'DELETE [] p' . Fortunately, in the particular case of a data-type without destructor (explicit or...
by fxm
Mar 23, 2020 6:34
Forum: General
Topic: Parse string to tree structure (solved)
Replies: 56
Views: 1642

Re: Parse string to tree structure

I changed my version, but it still crashes on Windows. It seems I cannot use redim. https://freebasic.net/wiki/wikka.php?wakka=KeyPgredim says: "Using Redim within a member procedure with an array that contains the instance of the object class is undefined, and will [hopefully] result in horri...
by fxm
Mar 20, 2020 6:42
Forum: Documentation
Topic: (SOLVED) Byref it seems incorrect description
Replies: 7
Views: 384

Re: (SOLVED) Byref it seems incorrect description

As it should not be confused: print @cptr(UDT ptr, 0)->c 'with: print cptr(UDT ptr, 0)->c similarly, it should not be confused: Dim Byref As datatype ref = *Cptr(datatype Ptr, 0) 'with: Dim As datatype ref = *Cptr(datatype Ptr, 0) The first two expressions correspond to an internal pointer value ass...
by fxm
Mar 20, 2020 5:54
Forum: Beginners
Topic: Need help with passing a parameter
Replies: 4
Views: 186

Re: Need help with passing a parameter

The way the code is currently written MinusExists changes its value in the subroutine but never passes it back. I tried to do it by changing the "byval" to "byref" but get a type mismatch error . To answer your initial question, this above is the right solution, but you must do ...
by fxm
Mar 19, 2020 8:39
Forum: Documentation
Topic: (SOLVED) Byref it seems incorrect description
Replies: 7
Views: 384

Re: (SOLVED) Byref it seems incorrect description

I think that these FreeBasic additional syntaxes (compared to C for example): Dim Byref As datatype ref = *Cptr(datatype Ptr, 0) 'and @ref = @other_variable will be preserved in future revisions (and I agree with that), because as @dkl said similarly in a post in August 2016 (https://www.freebasic.n...
by fxm
Mar 18, 2020 13:15
Forum: Documentation
Topic: Wiki improvements
Replies: 401
Views: 78501

Re: Wiki improvements

Thanks in advance.
by fxm
Mar 18, 2020 12:02
Forum: Documentation
Topic: (SOLVED) Byref it seems incorrect description
Replies: 7
Views: 384

Re: Byref it seems incorrect description

But for that, a two-line workaround (see Using References , paragraph 'Hacking on usage of references with the additional syntaxes allowed by FreeBASIC' ): type T dValue as double End Type '' Instead of 'dim shared byref sp as T = *new T', a two-line workaround dim shared byref sp as T = *cptr(T ptr...
by fxm
Mar 18, 2020 10:15
Forum: Documentation
Topic: (SOLVED) Byref it seems incorrect description
Replies: 7
Views: 384

Re: Byref it seems incorrect description

This problem is not exclusively due to the declaration of a reference, but more generally due to the initializer of the declaration 'Dim Shared' which must be a constant (or expression which can be evaluated at compile time, or global variable which can be evaluated at compilation). See the ...
by fxm
Mar 17, 2020 14:53
Forum: Beginners
Topic: need help with type mismatch error
Replies: 6
Views: 208

Re: need help with type mismatch error

Modifying or not a parameter inside a procedure does not modify the passing mode by default: ⋅ In '-lang fb dialect' , 'ByVal' is the default parameter passing convention for all built-in types except 'String' and 'User-Defined Type' which are passed 'By...
by fxm
Mar 17, 2020 14:04
Forum: Beginners
Topic: need help with type mismatch error
Replies: 6
Views: 208

Re: need help with type mismatch error

Inside your procedure 'ValidateLeadingSign()' , you want to modify in the global scope the values of the parameters 'Digit' , 'PlusExists' and 'MinusExists' . So these three must be passed by reference (pass only a copy is wrong). As by default a String is pas...
by fxm
Mar 17, 2020 12:24
Forum: General
Topic: Bin Oct Hex
Replies: 10
Views: 323

Re: Bin Oct Hex

@badidea, I don't know if you automatically applied the golden rules or my maximizing rule, but for such a type, the copy-constructor and the copy-assignment (from a same type instance) should be optional because a shallow copy of the member data ( '.value' here) is sufficient. But if we del...
by fxm
Mar 17, 2020 6:07
Forum: Beginners
Topic: need help with type mismatch error
Replies: 6
Views: 208

Re: need help with type mismatch error

The declarations of parameter types and passing modes must be matching between procedure declaration line and procedure definition line. By default, a String is passed by reference while a Byte is passed by value. It is why the compiler only rizes an error on PlusExists and MinusExists : declare sub...

Go to advanced search