Constructor (initializer_list)

hello this is my first post and i hope you can help me :)


at university we wrote a class simular to vector. it works my class works at university but not on my computer. in particular this constructor isnt working:
i include iostream
and use usesing namespace std;

header file:
Vector (initializer_list<double> );

Vector:: Vector(initializer_list <double> li){
max_sz=li.size();
sz=0;
if(max_sz) values = new double[max_sz];
else values = nullptr;
if (values){
for (const double& elem : li) values[sz++] =elem;
}
}

i use dev c++ 5.11, TDM-gcc 4.9.2

when i put gcc --version in my cmd it says 5.3.0




Last edited on
Are you are missing #include <initializer_list> in the header?

And, do not place using namespace std ; in the header file.
Use qualified names in the header. eg. Vector ( std::initializer_list<double> );

If you still get errors with gcc 5.3.0, post the entire contents of the header.
when i write "Vector ( std::initializer_list<double> );" its still the same error

when i include #include <initializer_list> i get this:

// Copyright (C) 2007-2014 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.

// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.

// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.

/** @file bits/c++0x_warning.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{iosfwd}
*/

#ifndef _CXX0X_WARNING_H
#define _CXX0X_WARNING_H 1

#if __cplusplus < 201103L
#error This file requires compiler and library support for the \
ISO C++ 2011 standard. This support is currently experimental, and must be \
enabled with the -std=c++11 or -std=gnu++11 compiler options.
#endif

#endif


how can i be sure that my dev c++ uses gcc 5.3.0?

my dev c++ path links to mingw/bin
By default, your GNU compiler assumes that the program is written in a home-grown linux dialect of C++ based on the obsoleted 1998 C++ standard.

You need to explicitly enable C++11 support.
See: http://www.cplusplus.com/doc/tutorial/introduction/devcpp/

To insist on standard C++ conformance (to the extent possible), also specify -pedantic-errors
thank you so much

can now start to worry how i manage my homework ( still no idea about that^^)
but i go on now.

thank you so much!!!!!
Topic archived. No new replies allowed.