Topic: automatic variables


Author: "Sarath" <CSarath@gmail.com>
Date: Thu, 1 Mar 2007 13:28:49 CST
Raw View
In the new standard we can have automatic variables.

like auto f = 10.1f;

in this case f will be float.

suppose if I've two overloaded functions

int GetValue();
float GetValue();

now... I'm calling

auto f = GetValue();

Now which function will be called? I'm not sure whether my doubt
making some sense

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





Author: hyrosen@mail.com (Hyman Rosen)
Date: Thu, 1 Mar 2007 20:01:09 GMT
Raw View
Sarath wrote:
> suppose if I've two overloaded functions
> int GetValue(); float GetValue();

It's illegal to have overloaded functions that differ
only in return type. This isn't Ada, you know!

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





Author: ricecake@gehennom.invalid (Marcus Kwok)
Date: Thu, 1 Mar 2007 14:56:28 CST
Raw View
Sarath <CSarath@gmail.com> wrote:
> In the new standard we can have automatic variables.
>
> like auto f = 10.1f;
>
> in this case f will be float.
>
> suppose if I've two overloaded functions
>
> int GetValue();
> float GetValue();
>
> now... I'm calling
>
> auto f = GetValue();
>
> Now which function will be called? I'm not sure whether my doubt
> making some sense

You cannot overload functions only on return type, for the very reason
that the call will be ambiguous.

--
Marcus Kwok
Replace 'invalid' with 'net' to reply

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