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

C

chetan

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 ...!!!!
 
K

Karthik Kumar

chetan said:
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 ----
 
J

John Harrison

chetan said:
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
 
R

Ron Natalie

chetan said:
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.
 
C

chetan

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
 
J

John Harrison

chetan said:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,010
Latest member
MerrillEic

Latest Threads

Top