tags:

views:

101

answers:

2

I am trying to learn how to use implicitly typed variables in c++.

Should i be using 'auto' from C++0x? If so how?

Can some one provide me with a simple example or a good tutorial on this?

Thank you.

+1  A: 
auto x = f();

The type of x will be whatever f() returns.

sbi
also x has to be cast back into the type f() returns :)
LoudNPossiblyRight
@LoudNPossiblyRight: I have no idea what you are trying to say. (Whatever interpretation I can come up with seems wrong.)
sbi
+2  A: 

Check out this explanation from Bjarne Stroustrup himself: auto -- deduction of a type from an initializer.

Brian Neal