Re: [fpc-pascal] Re: Problem with virtual constructors

2011-06-01 Thread Jorge Aldo G. de F. Junior
2011/6/1 leledumbo leledumbo_c...@yahoo.co.id:
 Yep, this situation would confuse the compiler as it's possible to assign
 descendant class instance to a class.
 1st solution: rename one of the constructor, don't need to use
 virtual/override

Its a class factory, i cannot have multiple constructors, so i need
virtual constructors in order to build classes from names.

 2nd solution: try using constref instead of const (I hope constref has the
 same semantics as var for classes, where the assigned object must be exactly
 the instance of expected class, descendants not allowed)

I will try that.


 --
 View this message in context: 
 http://free-pascal-general.1045716.n5.nabble.com/Problem-with-virtual-constructors-tp4445729p4445832.html
 Sent from the Free Pascal - General mailing list archive at Nabble.com.
 ___
 fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
 http://lists.freepascal.org/mailman/listinfo/fpc-pascal

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Re: Problem with virtual constructors

2011-06-01 Thread Jorge Aldo G. de F. Junior
Cobines solution worked !

not tested constref.

2011/6/1 Jorge Aldo G. de F. Junior jagf...@gmail.com:
 2011/6/1 leledumbo leledumbo_c...@yahoo.co.id:
 Yep, this situation would confuse the compiler as it's possible to assign
 descendant class instance to a class.
 1st solution: rename one of the constructor, don't need to use
 virtual/override

 Its a class factory, i cannot have multiple constructors, so i need
 virtual constructors in order to build classes from names.

 2nd solution: try using constref instead of const (I hope constref has the
 same semantics as var for classes, where the assigned object must be exactly
 the instance of expected class, descendants not allowed)

 I will try that.


 --
 View this message in context: 
 http://free-pascal-general.1045716.n5.nabble.com/Problem-with-virtual-constructors-tp4445729p4445832.html
 Sent from the Free Pascal - General mailing list archive at Nabble.com.
 ___
 fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
 http://lists.freepascal.org/mailman/listinfo/fpc-pascal


___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal