Simulatneous declare/initialize member variable

From: Fred Ma (fma_at_doe.carleton.ca)
Date: 05/31/04


Date: 31 May 2004 03:08:07 GMT

Are there any reasons that would make it bad for C++ to
allow simultaneous declaration and initilization of member data?

Current way:
------------

class DerivedClass : BaseClass {
{
   enum { lengthSV=16 }; // Length of SomeVector
   vector<double> SomeVector;

   DerivedClass( void ) : BaseClass( SomeArgument ), SomeVector(lengthSV,0.0)
   {
      // Construction of Derived Class
   };
};

Better/Worse way?
-----------------

class DerivedClass : BaseClass {
{
   enum { lengthSV=16 }; // Length of SomeVector
   vector<double> SomeVector(lengthSV);

   DerivedClass( void ) : BaseClass( SomeArgument )
   {
      // Construction of Derived Class
   };
};

Fred

-- 
Fred Ma
Dept. of Electronics, Carleton University
Ottawa, Ontario, Canada


Relevant Pages

  • Re: Intermittent compiler error
    ... from another nested class within the parent class' base class. ... > public class DerivedClass ... > public mustinherit class BaseClass ... > public mustinherit class NestedClass ...
    (microsoft.public.dotnet.general)
  • Is vs IsAssignableFrom to detect and interface
    ... I have an interface IMyInterface that is implemented by BaseClass. ... also have a class DerivedClass that is inherited from BaseClass. ... TypetPossibleTypes; ... the is keyword does not detect the interface IMyInterface. ...
    (microsoft.public.dotnet.framework)
  • Re: cool thing with memberfunction pointers as parameters
    ... > void CallVirtual(BaseClassFunc pF, void* ... > class DerivedClass: public BaseClass ...
    (comp.lang.cpp)