typedf inC++

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nanimun
    New Member
    • Nov 2007
    • 2

    typedf inC++

    i facing one problem that is

    i was used "typedf"to main function as followes

    typedf int main(void)
    {
    int a=10;
    cout<<"name";
    cout<<"adress";
    cout<<a
    } nanimun

    this is i was done
    i dotknow what is the pronlem
    plz help me
  • mohammadazim
    New Member
    • Aug 2007
    • 28

    #2
    You are tring to do typedef of a function definetion. That is not possible.
    You can do typedef of a function declaration as
    typedef int main(void);
    but then it won't allow you to define main in the same file and if you write a c program without a main, it will give linking error "undefined reference to main".

    But I don't understand why you want to do this. Actually we do tydef so that we can use the typename instead of declaring same type of thing again. If your requirement is same, why don't you use some other name like
    tydef int func(void);

    May be I did't understood your requirement. Don't consider my response your answer. I'll also wait for some one else to answer you.

    Comment

    • nanimun
      New Member
      • Nov 2007
      • 2

      #3
      just tellme that
      how it is declared

      Comment

      • mohammadazim
        New Member
        • Aug 2007
        • 28

        #4
        typedef int main(void);

        Comment

        Working...