Thread: What is wrong with the constructor initialization?

  1. #1
    Registered User
    Join Date
    Sep 2012
    Posts
    86

    What is wrong with the constructor initialization?

    .cpp
    Code:
    bloomfilter::bloomfilter(int m, long long p, int c):primenumber(p), tablesize(m), hashfunctions(c), vector <int> A(c), vector <int> B (c){
    }
    
    Code:
    .h
    public: bloomfilter(int, long long, int);
    It saying overloaded, but my parameters are declared.

  2. #2
    Registered User MutantJohn's Avatar
    Join Date
    Feb 2013
    Posts
    2,665
    I thin you have to construct in the same order your arguments are declared.

  3. #3
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Why do your last two variables in the initialization list have types?

  4. #4
    Registered User
    Join Date
    Dec 2006
    Location
    Canada
    Posts
    3,229
    Quote Originally Posted by MutantJohn View Post
    I thin you have to construct in the same order your arguments are declared.
    Members are initialized in the order they are declared in the class. The order of initialization list is irrelevant, though most compilers will warn you if it differs from the order they are declared.

  5. #5
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    Quote Originally Posted by cyberfish View Post
    Members are initialized in the order they are declared in the class. The order of initialization list is irrelevant, though most compilers will warn you if it differs from the order they are declared.
    I would say - some compilers would do it, since it could misguide the programmer reading the code to believe wrong order of initializations based on initializes list.
    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

  6. #6
    Registered User MutantJohn's Avatar
    Join Date
    Feb 2013
    Posts
    2,665
    Quote Originally Posted by cyberfish View Post
    Members are initialized in the order they are declared in the class. The order of initialization list is irrelevant, though most compilers will warn you if it differs from the order they are declared.
    Ah, thank you for correcting me. I knew it was something like that where if you weren't using an explicit constructor (where you use curly brackets in lieu of : ) the order mattered, I just wasn't sure on the order of what.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Constructor Initialization/operator overloading
    By MattJ812 in forum C++ Programming
    Replies: 3
    Last Post: 12-25-2010, 01:24 PM
  2. Constructor Initialization
    By Kane in forum C++ Programming
    Replies: 5
    Last Post: 04-05-2007, 07:12 AM
  3. Replies: 9
    Last Post: 10-26-2005, 07:29 AM
  4. Something wrong in initialization?
    By Shadow12345 in forum C++ Programming
    Replies: 1
    Last Post: 04-26-2002, 01:42 PM
  5. Class constructor with initialization
    By WebSnozz in forum C++ Programming
    Replies: 1
    Last Post: 11-20-2001, 05:31 PM