Thread: Passing Objects to Constructors and Receiving a Logic Error

  1. #1
    Drunken Progammer CaptainMorgan's Avatar
    Join Date
    Feb 2006
    Location
    On The Rocks
    Posts
    45

    Passing Objects to Constructors and Receiving a Logic Error

    If anyone would be so kind... I do not know why I am receiving the below error. Desired output is also given.

    Code:
    Foobasesbase::Foobasesbase( const string& one, const string& two, const string& three ) 
      : onedata( one ), twodata( two ), threedata( three ) 
    { 
      cout << "Foobasesbase constructor called." << endl; 
    } 
    
    
    Foobase::Foobase( const string& one, const string& two, const string& three, const string& four, 
                      const string& five, const string& six ) 
      : Foobasesbase( one, two, three ), fourdata( four ), fivedata( five ), sixdata( six ) 
    { 
      cout << "Foobase constructor called." << endl; 
    } 
    
    
    Foo:Foo( const string& one, const string& two, const string& three, const string& four,  
             const string& five, const string& six, const string& seven, const string& eight ) 
      : FooBase( FooBasesBase( one, two, three ), four, five, six ), foosev( seven ), fooeig( eight ) 
    { 
      cout << "Foo constructor called." << endl; 
    } 
    
    
    
    // error 
    Foobasesbase constructor called. 
    Foobase constructor called. 
    Foobasesbase destructor called. 
    Foo constructor called. 
    fourdata, fivedata, sixdata, sevendata, eightdata 
    Foo destructor called. 
    Foobase destructor called. 
    Foobasesbase destructor called. 
    
    // desired output 
    Foobasesbase constructor called. 
    Foobase constructor called. 
    Foo constructor called. 
    onedata, twodata, threedata 
    fourdata, fivedata, sixdata, sevendata, eightdata 
    Foo destructor called. 
    Foobase destructor called. 
    Foobasesbase destructor called.
    Thank you.
    Last edited by CaptainMorgan; 11-18-2006 at 05:21 AM.

  2. #2
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    Code:
    Foo:Foo( const string& one, const string& two, const string& three, const string& four,  
             const string& five, const string& six, const string& seven, const string& eight ) 
      : FooBase( one, two, three , four, five, six ), foosev( seven ), fooeig( eight )
    maybe?
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  3. #3
    Drunken Progammer CaptainMorgan's Avatar
    Join Date
    Feb 2006
    Location
    On The Rocks
    Posts
    45
    Ah... thank you.

Popular pages Recent additions subscribe to a feed