Unix Borland C++ Compiler Error - Something about parameter passing

This is a discussion on Unix Borland C++ Compiler Error - Something about parameter passing within the C++ Programming forums, part of the General Programming Boards category; "The constructor initializer is unexpected. All bases and members have been initialized." Code is Code: template <class TYPE> ChainHash<TYPE>::ChainHash(int max):Hash(max,max){ ...

  1. #1
    Registered User
    Join Date
    Nov 2004
    Posts
    93

    Arrow Unix AIX V5.0 C++ Compiler Error - Something about parameter passing

    "The constructor initializer is unexpected. All bases and members have been initialized."

    Code is

    Code:
    template <class TYPE>
    ChainHash<TYPE>::ChainHash(int max):Hash(max,max){
    	h_size = 0;
    	C_Table = new CList<TYPE>[cap()];
    }
    This works just beautiful when compiling under Visual Studio 2005 in a console project.

    It doesnt like the base parameter passing, is there another way to fix this? I was always taught to use pass to the base through the constructor definition there.

    Edit: It's an AIX compiler and not borland.
    Last edited by INFERNO2K; 11-10-2006 at 11:10 PM.

  2. #2
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,465
    > I was always taught to use pass to the base through the constructor definition there.

    One thing that occurs to me is if that base class constructor has default values, it will act has a default constructor, thus it will be automatically called by ChainHash() constructor.

    Can it be that you have Hash declared as Hash(int = something, int = something) ?
    The programmer’s wife tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”
    The programmer comes home with 12 loaves of bread.


    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  3. #3
    Registered User
    Join Date
    Nov 2004
    Posts
    93
    Well Hash is an abstract class and the only other time I refer to it is in another classes constructor as well, for base initialization

    Code:
    template <class TYPE>
    LPHash<TYPE>::LPHash(int max, double over):Hash<TYPE>(max,(int)(max*over)+max){
    
    	// Create a new array of HashEntries and set size to 0
    	LP_HTable = new HashEntry<TYPE>[cap()];	
    	h_size = 0;
    }

  4. #4
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,465
    Show us the ABC definition please
    The programmer’s wife tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”
    The programmer comes home with 12 loaves of bread.


    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  5. #5
    Registered User
    Join Date
    Nov 2004
    Posts
    93
    Code:
    template <class TYPE>
    class Hash{
    
    	public:
    			Hash(int max, int cap);
    			Hash();
    			virtual ~Hash();
    			virtual bool remove(const char* key)=0;
    			virtual bool find(const char* key, TYPE& holder)=0;
    			virtual bool update(const TYPE& data)=0;
    			int cap() const;
    			int max() const;
    			int size() const;
    			double loadfactor() const;
    
    	private:
    			int h_max;
    			int h_cap;
    	
    	protected:
    			int h_size;
    
    };
    
    template <class TYPE>
    Hash<TYPE>::~Hash(){
    }
    
    template <class TYPE>
    Hash<TYPE>::Hash(){
    }
    
    template <class TYPE>
    Hash<TYPE>::Hash(int max, int cap){
    	h_max = max;
    	h_cap = cap;
    	h_size = 0;
    }
    
    template <class TYPE>
    int Hash<TYPE>::cap() const{
    	return h_cap;
    }
    
    template <class TYPE>
    int Hash<TYPE>::max() const{
    	return h_max;
    }
    
    template <class TYPE>
    int Hash<TYPE>::size() const{
    	return h_size;
    }
    
    template <class TYPE>
    double Hash<TYPE>::loadfactor() const{
    	return (double)((double)h_size/(double)h_cap);	
    }

  6. #6
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,465
    Well... no default parameters there. But I did notice that you are missing a template argument:

    Code:
    template <class TYPE>
    ChainHash<TYPE>::ChainHash(int max):Hash<TYPE>(max,max){
    	h_size = 0;
    	C_Table = new CList<TYPE>[cap()];
    }
    Why AIX doesn't report this error but decides instead to use the default constructor and simply name the above as unnecessary, beats me. However, that should solve your problem.
    Last edited by Mario F.; 11-11-2006 at 08:54 AM.
    The programmer’s wife tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”
    The programmer comes home with 12 loaves of bread.


    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. parameter passing?
    By theLukerBoy in forum C Programming
    Replies: 3
    Last Post: 11-03-2002, 05:25 PM
  2. Replies: 2
    Last Post: 03-30-2002, 11:34 PM
  3. parameter passing
    By Jax in forum C Programming
    Replies: 4
    Last Post: 11-07-2001, 04:24 AM
  4. Passing a parameter into the executable
    By neva4getme in forum C Programming
    Replies: 2
    Last Post: 10-11-2001, 01:18 PM
  5. passing a parameter to a system invoke
    By iain in forum C++ Programming
    Replies: 1
    Last Post: 09-18-2001, 09:21 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21