Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

what does the 'extern' keyword do?

ITAITA Member Posts: 463
I've seen the extern keyword used a lot in other people's programs, but I've never used it myself, and I've no idea what it does.

Please could someone help,

many thanks,

ITA
"Let us smite the evil slime eating hordes who may befall us on our quest to be the ultimate programmers of the known universe!"

Comments

  • DonotaloDonotalo Member Posts: 715
    [b][red]This message was edited by Donotalo at 2005-8-8 9:4:18[/red][/b][hr]
    preciding a variable name with extern specifier, u can use a variable without defining it. for an example:
    [code]
    main() {
    extern int a;[green]//use global varible[/green]
    cout << a << endl;
    }
    int a = 10;[green]//a is declared and defined here[/green]
    [/code]

    Output will be the number 10.

    however, the declaration of [blue]a[/blue] may be in another file that comprise ur program.


  • ITAITA Member Posts: 463
    : [b][red]This message was edited by Donotalo at 2005-8-8 9:4:18[/red][/b][hr]
    : preciding a variable name with extern specifier, u can use a variable without defining it. for an example:
    : [code]
    : main() {
    : extern int a;[green]//use global varible[/green]
    : cout << a << endl;
    : }
    : int a = 10;[green]//a is declared and defined here[/green]
    : [/code]
    :
    : Output will be the number 10.
    :
    : however, the declaration of [blue]a[/blue] may be in another file that comprise ur program.
    :
    :
    :


    thx
    "Let us smite the evil slime eating hordes who may befall us on our quest to be the ultimate programmers of the known universe!"

Sign In or Register to comment.