Sign in to follow this  
FDsagizi

asEP_ALWAYS_IMPL_DEFAULT_CONSTRUCT, true

Recommended Posts

FDsagizi    514

Hi Andreas smile.png

 

with asEP_ALWAYS_IMPL_DEFAULT_CONSTRUCT we can create all objects from c++ code, for deserealization - It work fine!

but, for scripts, i think no need use this.

 

exemple:

this code work, but it's not goood

 

 

 

 

class SomeClass{
     SomeClass( int init_param ){}
}
void f(){
     SomeClass s;
}
 

 

Share this post


Link to post
Share on other sites
WitchLord    4678
The flag asEP_ALWAYS_IMPL_DEFAULT_CONSTRUCT is to tell the compiler to implement the default constructor even though the class has a defined non-default constructor. This is mostly used for backwards compatibility as it was the behaviour in the compiler before version 2.22.1. When deserializing objects you should use the method CreateUninitializedScriptObject() to get the object and then fill out all the members explicitly.

Share this post


Link to post
Share on other sites
FDsagizi    514
yes you are absolutely right!
CreateUninitializedScriptObject work from c++ - and this good, but def counstructor we can use from script - it's not good!
I want to even when the flag is set, it shows an error - not defined a default constructor( only from script ).
 
ex:
 

 

// asEP_ALWAYS_IMPL_DEFAULT_CONSTRUCT, false
class SomeClass{
     SomeClass( int init_param ){}
}
void f(){
     SomeClass s; // No default constructor for object of type 'SomeClass'.
}

//-----------------------------------------------------------------------------

//next 
// asEP_ALWAYS_IMPL_DEFAULT_CONSTRUCT, true ( current time )
class SomeClass{
     SomeClass( int init_param ){}
}
void f(){
     SomeClass s; // work
}

//-----------------------------------------------------------------------------

// a want to, we set asEP_ALWAYS_IMPL_DEFAULT_CONSTRUCT true, and we have - 
class SomeClass{
     SomeClass( int init_param ){}
}
void f(){
     SomeClass s; // No default constructor for object of type 'SomeClass'.
}
// add constructor
class SomeClass{
     SomeClass(){  /* def constructor */ }      
     SomeClass( int init_param ){}
}
void f(){
     SomeClass s; // work
}

 

Edited by FDsagizi

Share this post


Link to post
Share on other sites
FDsagizi    514

No. Since you don't want the default constructor to be available automatically, then you should _not_ set the flag asEP_ALWAYS_IMPL_DEFAULT_CONSTRUCT to true.

oh yes, im sorry!rolleyes.gif

i thinking CreateUninitializedScriptObject work only with asEP_ALWAYS_IMPL_DEFAULT_CONSTRUCT to true.

cool!smile.png 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this