Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.std.c++ > #326

Re: can Variable initialized by function?

From pasa<pasa@lib.hu>
Newsgroups comp.std.c++
Subject Re: can Variable initialized by function?
Date 2011-10-15 09:28 -0700
Organization http://groups.google.com
Message-ID <79be454a-1f36-4e15-a72d-e8ef6fbb462d@s14g2000vbj.googlegroups.com> (permalink)
References <7008aaa3-2d64-42c0-933e-14046782d918@i28g2000yqn.googlegroups.com>

Show all headers | View raw


"Evan Zeng"<evanzengcn@gmail.com>

at global scope:
>       int i=func(1,2);
>  And it compiled sucessefully  by g++, while has  error by gcc. Can
>  anyone explain it in details?

This is good in C++ and uses dynamic init before entering main(),
calling
func() to provide initial value of i.

But C has only static init, you can only use initializers vith
constant
expression, so the compiler can figure out the value right ahead.


-- 
[ comp.std.c++ is moderated.  To submit articles, try posting with your ]
[ newsreader.  If that fails, use mailto:std-cpp-submit@vandevoorde.com ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]

Back to comp.std.c++ | Previous | NextPrevious in thread | Find similar


Thread

can  Variable initialized by function? Evan Zeng<evanzengcn@gmail.com> - 2011-10-07 16:08 -0700
  Re: can  Variable initialized by function? Daniel Krügler<daniel.kruegler@googlemail.com> - 2011-10-08 09:36 -0700
  Re: can Variable initialized by function? pasa<pasa@lib.hu> - 2011-10-15 09:28 -0700

csiph-web