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

  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-11-2006 at 12:10 AM.

  2. #2
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    > 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) ?
    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
    Ireland
    Posts
    8,446
    Show us the ABC definition please
    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
    Ireland
    Posts
    8,446
    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 09:54 AM.
    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, 06:25 PM
  2. Replies: 2
    Last Post: 03-31-2002, 12:34 AM
  3. parameter passing
    By Jax in forum C Programming
    Replies: 4
    Last Post: 11-07-2001, 05: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