Announcement

Collapse
No announcement yet.

About struct's extension : actually a "little" useless

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

    About struct's extension : actually a "little" useless

    Little example:
    Code:
    struct BaseStruct
    {
        var bool IsUsed;
        structdefaultproperties
        {
            IsUsed = false
        }
    };
    
    struct AnotherStruct extends BaseStruct
    {
        //add some other stuffs
    };
    
    var BaseStruct A;
    var AnotherStruct B;
    
    function SetUsed(out BaseStruct S)
    {
        S.IsUsed = true;
    } 
    
    function MyFunction()
    {
        SetUsed(A); //ok
        SetUsed(B); //error
    }
    Here's the error:
    Code:
    Error, Call to 'SetUsed', parameter 1: Type mismatch in Out variable
    Seriously, it's like extending a class without getting parent's methods and properties: totally useless.
    And i find the struct extension very useful in many situations.

    #2
    Hmm… can you typecast B to the BaseStruct when calling that function?

    Comment


      #3
      using

      Code:
      SetUsed( BaseStruct(B) );
      result:

      Code:
      Error, Bad or missing expression for token: MyFunction, in Call to 'BaseStruct', parameter 1
      (p.s. : Ty for your reply, Crusha)

      Comment


        #4
        Sorry for the bump, any news/solution about this?
        I find them extremely useful...

        Comment


          #5
          Using objects instead of structs would solve this issue.

          Comment

          Working...
          X