How c++ Compiler understands the which is the private func and which is the public fun ????

Discussion in 'C++' started by chetan, Sep 20, 2004.

  1. chetan

    chetan Guest

    Hi ,
    myself Chetan

    I want to know that how does the g++ or any other C++ compiler
    understands the
    which is the public and which the private function that is getting
    envoked at compile time ??

    If only the object is given (exported) to user and he is unaware of
    the public and the private functions or data .... ?

    Does it puts any special information in the object file that it
    creates during ?

    Or any else happens ?

    Please reply me any related link or anything as such ...!!!!
    chetan, Sep 20, 2004
    #1
    1. Advertising

  2. Re: How c++ Compiler understands the which is the private func andwhich is the public fun ????

    chetan wrote:
    > Hi ,
    > myself Chetan
    >
    > I want to know that how does the g++ or any other C++ compiler
    > understands the
    > which is the public and which the private function that is getting
    > envoked at compile time ??
    >
    > If only the object is given (exported) to user and he is unaware of
    > the public and the private functions or data .... ?


    The development process for C++ libraries is roughly like this -

    * The developer would publish the interface of the library (header
    files) + the library files. (in case, that is not open source - Else,
    of course, you would be given the source files and makefiles).

    So to know the public / private methods (well, you should not be
    needing private methods anyway), you need access to the header files.

    >
    > Does it puts any special information in the object file that it
    > creates during ?


    C++ standard does not specify any of these details.
    >
    > Or any else happens ?
    >
    > Please reply me any related link or anything as such ...!!!!


    Get to a good C++ book and the first couple of chapters should
    explain these basics.


    --
    Karthik.
    ------------ And now a word from our sponsor ---------------------
    For a secure high performance FTP using SSL/TLS encryption
    upgrade to SurgeFTP
    ---- See http://netwinsite.com/sponsor/sponsor_surgeftp.htm ----
    Karthik Kumar, Sep 20, 2004
    #2
    1. Advertising

  3. "chetan" <> wrote in message
    news:...
    > Hi ,
    > myself Chetan
    >
    > I want to know that how does the g++ or any other C++ compiler
    > understands the
    > which is the public and which the private function that is getting
    > envoked at compile time ??


    Simple, the compiler looks at the headr file to work out which functions are
    public and which are private.

    >
    > If only the object is given (exported) to user and he is unaware of
    > the public and the private functions or data .... ?


    A user cannot compile without a header file as well.

    >
    > Does it puts any special information in the object file that it
    > creates during ?


    No.

    >
    > Or any else happens ?


    No.

    john
    John Harrison, Sep 20, 2004
    #3
  4. chetan

    Ron Natalie Guest

    "chetan" <> wrote in message news:...

    > I want to know that how does the g++ or any other C++ compiler
    > understands the
    > which is the public and which the private function that is getting
    > envoked at compile time ??
    >

    Access control is known at compile time as the class declaration must be
    seen to access any of the members. Public vs. private has no bearing on
    WHICH function gets invoked only IF it can be invoked.
    Ron Natalie, Sep 20, 2004
    #4
  5. chetan

    chetan Guest

    Hi
    I understood what you told ,,but

    Actually I am working on my B.E. Project... in C++

    and I am in great confusion that should I export the PUBLIC methods
    OR should I export the previosly created objects OR should I export
    the constructors of the class (I made them private so as to follow
    singletan )of that class so that those can be used by the user
    program/module ..

    But in exporting the any method harm is that..
    user won't be able to understand which is is the public and which is
    private

    so it would cause the compiler error..!!!

    Or he may simply change contents of the header file from private to
    public
    and simply get compiled without any errors..!!!

    So is there any book to tell me that from where C++ compiler verified
    that
    function called is public and doesn't generate any error..!!!
    ....Chetan
    chetan, Sep 21, 2004
    #5
  6. "chetan" <> wrote in message
    news:...
    > Hi
    > I understood what you told ,,but
    >
    > Actually I am working on my B.E. Project... in C++
    >
    > and I am in great confusion that should I export the PUBLIC methods
    > OR should I export the previosly created objects OR should I export
    > the constructors of the class (I made them private so as to follow
    > singletan )of that class so that those can be used by the user
    > program/module ..


    Exporting of methods is not part of C++. You must be working with some
    compiler extension to C++. So you should ask in a group for your compiler.
    Your question is not part of C++, in C++ we have header files not exporting.

    john
    John Harrison, Sep 21, 2004
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. DaveLessnau
    Replies:
    3
    Views:
    408
    Howard
    May 16, 2005
  2. Johnny
    Replies:
    3
    Views:
    436
    Robert Kern
    Aug 23, 2005
  3. Hari Sekhon
    Replies:
    0
    Views:
    478
    Hari Sekhon
    Jun 20, 2006
  4. Alex Vinokur
    Replies:
    6
    Views:
    338
    Tor Rustad
    Nov 18, 2006
  5. dmitrey
    Replies:
    4
    Views:
    1,004
    Diez B. Roggisch
    Aug 11, 2009
Loading...

Share This Page