|
From: Maya <Esc...@ne...> - 2004-01-31 12:14:33
|
In the first one you have declared a struct named _Human and
instantiated it right after the declaration with name Human. In your
program you can just say for instance: " Human.height = 1.70 " and it
will work
Here is another example:
typedef struct _Human {
int height;
}Human;
int main(){
std::cout << "The Human Project" << std::endl;
std::cout << "How tall are you " ;
std::cin >> Human.height;
return 0;
}
In the second example you have declared a struct named Human, but has
not yet been instantiated.
Your code would look something like this
struct Human {
int height;
};
int main(){
Human human; // Instantiating the Human struct
std::cout << "The Human Project" << std::endl;
std::cout << "How tall are you " ;
std::cin >> human.height; // <<==
return 0;
}
Which one is better? it depends on the program you are working on, really!
Hava a good one!
coo...@ho... wrote:
> what is the difference between these two
>
> typedef struct _Human
> {
> int height;
> }Human;
>
> struct Human
> {
> int height;
> };
>
>
> and in the first one, what does 'Human' mean at the end? In both
> structs u can declare a Human type, even without the Human thing at
> the end in the first one
>
> _________________________________________________________________
> STOP MORE SPAM with the new MSN 8 and get 2 months FREE*
> http://join.msn.com/?page=dept/bcomm&pgmarket=en-ca&RU=http%3a%2f%2fjoin.msn.com%2f%3fpage%3dmisc%2fspecialoffers%26pgmarket%3den-ca
>
>
>
>
> -------------------------------------------------------
> The SF.Net email is sponsored by EclipseCon 2004
> Premiere Conference on Open Tools Development and Integration
> See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
> http://www.eclipsecon.org/osdn
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
--
FYI
http://www.astro.umd.edu/~marshall/abbrev.html
E-Mail Policy
http://www.vif.com/users/escalante/Email_Policy.html
* You cannot exercise your power to a point of humiliation.
- Jean Chretien
* The media's the most powerful entity on earth. They have the
power to make the innocent guilty and to make the guilty
innocent, and that's power.
- Malcom X
* "Innocent until proven guilty", no... not in Canada!!
|