class base
{
  private:
        int i;

        void seti( int i_temp ) // :i(i_temp) ->Initializer List not working
        {
             i = i_temp;
        }

  public:

        base()
        {

        }

        base( int t ):seti( t )
        {

        }
};

error C2436: 'seti' : member function or nested class in constructor initializer list.

That is the error i get for the code above it. could someone please tell me where im err-ing?

// ...
        base( int t ) : i(t) {} // initialize member i with t
       // ...
// ...
        base( int t ) : i(t) {} // initialize member i with t
       // ...

yes it works. but why doesn't this work

base( int t ): seti( t )
        {

        }

Afterall im jus calling a private function to initialize 'i'.

you can call functions inside the body of the constructor. colon initialization can be used only for initialization of members or base classes (using copy constructor semantics).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.