Hi,
for whom the header files are important?
for the programmer or for the compiler..??
As the programmer very well sees all the private data of a class
through the header file ..but if he tries to access it then the
compiler throws the error..
Thanks and Regards,
Yogesh Joshi 11 1321 yo******@gmail.com wrote:
Hi,
for whom the header files are important?
for the programmer or for the compiler..??
As the programmer very well sees all the private data of a class
through the header file ..but if he tries to access it then the
compiler throws the error..
Header files allow you to create "interfaces" and reusability of code.
As for private data, you can, if you wish, hide all your private
elements in the cpp file. yo******@gmail.com wrote:
for whom the header files are important?
for the programmer or for the compiler..??
The compiler.
As the programmer very well sees all the private data of a class
through the header file ..but if he tries to access it then the
compiler throws the error..
The programmer is supposed to read the documentation/specs. Stuff in the
headers are implementation details.
Best
Kai-Uwe Bux yo******@gmail.com wrote:
Hi,
for whom the header files are important?
for the programmer or for the compiler..??
As the programmer very well sees all the private data of a class
through the header file ..but if he tries to access it then the
compiler throws the error..
Thanks and Regards,
Yogesh Joshi
As far as the compiler is concerned, header files don't exist.
That is, until you include them into your source(s).
And nothing stops you from accessing the private parts of a class,
either.
Thats what accessors and public member functions are for.
Compilers generate errors because the declaration of the class is a set
of rules the compiler must obey and enforce. yo******@gmail.com wrote:
Hi,
for whom the header files are important?
for the programmer or for the compiler..??
As the programmer very well sees all the private data of a class
through the header file ..but if he tries to access it then the
compiler throws the error..
Thanks and Regards,
Yogesh Joshi
You should read a C++ book please.
Salt_Peter wrote:
yo******@gmail.com wrote:
Hi,
for whom the header files are important?
for the programmer or for the compiler..??
As the programmer very well sees all the private data of a class
through the header file ..but if he tries to access it then the
compiler throws the error..
Thanks and Regards,
Yogesh Joshi
As far as the compiler is concerned, header files don't exist.
That is, until you include them into your source(s).
And nothing stops you from accessing the private parts of a class,
either.
Thats what accessors and public member functions are for.
Compilers generate errors because the declaration of the class is a set
of rules the compiler must obey and enforce.
Yes..got it..merely seeing the private variables doesn't mean you have
access to that..
Thanks and Regards,
Yogesh Joshi yo******@gmail.com wrote:
Salt_Peter wrote:
yo******@gmail.com wrote:
Hi,
>
for whom the header files are important?
>
for the programmer or for the compiler..??
As the programmer very well sees all the private data of a class
through the header file ..but if he tries to access it then the
compiler throws the error..
>
>
Thanks and Regards,
Yogesh Joshi
As far as the compiler is concerned, header files don't exist.
That is, until you include them into your source(s).
And nothing stops you from accessing the private parts of a class,
either.
Thats what accessors and public member functions are for.
Compilers generate errors because the declaration of the class is a set
of rules the compiler must obey and enforce.
Yes..got it..merely seeing the private variables doesn't mean you have
access to that..
Thanks and Regards,
Yogesh Joshi
Not neccessarily true.
class N
{
int n;
public:
N() : n(0) { }
void set(int x) { n = x; }
int get() const { return n; }
};
I can see, modify and access the private integer n.
Salt_Peter wrote:
yo******@gmail.com wrote:
Salt_Peter wrote:
yo******@gmail.com wrote:
Hi,
for whom the header files are important?
for the programmer or for the compiler..??
As the programmer very well sees all the private data of a class
through the header file ..but if he tries to access it then the
compiler throws the error..
Thanks and Regards,
Yogesh Joshi
>
As far as the compiler is concerned, header files don't exist.
That is, until you include them into your source(s).
And nothing stops you from accessing the private parts of a class,
either.
Thats what accessors and public member functions are for.
Compilers generate errors because the declaration of the class is a set
of rules the compiler must obey and enforce.
Yes..got it..merely seeing the private variables doesn't mean you have
access to that..
Thanks and Regards,
Yogesh Joshi
Not neccessarily true.
class N
{
int n;
public:
N() : n(0) { }
void set(int x) { n = x; }
int get() const { return n; }
};
I can see, modify and access the private integer n.
>>>>Yes..got it..merely seeing the private variables doesn't mean you have >access to that..
sorry ..what I mean to say was..accessing the private variables
directly..i.e without using any member functions..
(I also come across this statement that " getter and setter functions
reveal the internal implementation details of the class and should be
avoided..")
cheers,
Yogesh Joshi yo******@gmail.com wrote:
Salt_Peter wrote:
yo******@gmail.com wrote:
Salt_Peter wrote: yo******@gmail.com wrote:
Hi,
>
for whom the header files are important?
>
for the programmer or for the compiler..??
As the programmer very well sees all the private data of a class
through the header file ..but if he tries to access it then the
compiler throws the error..
>
>
Thanks and Regards,
Yogesh Joshi
As far as the compiler is concerned, header files don't exist.
That is, until you include them into your source(s).
And nothing stops you from accessing the private parts of a class,
either.
Thats what accessors and public member functions are for.
Compilers generate errors because the declaration of the class is a set
of rules the compiler must obey and enforce.
>
Yes..got it..merely seeing the private variables doesn't mean you have
access to that..
>
Thanks and Regards,
Yogesh Joshi
Not neccessarily true.
class N
{
int n;
public:
N() : n(0) { }
void set(int x) { n = x; }
int get() const { return n; }
};
I can see, modify and access the private integer n.
>>>Yes..got it..merely seeing the private variables doesn't mean you have access to that..
sorry ..what I mean to say was..accessing the private variables
directly..i.e without using any member functions..
You still can, but only if you abuse the system:
N n;
int * n_member = reinterpret_cast<int*>(&n);
n_member = 5;
Noah Roberts wrote:
....
You still can, but only if you abuse the system:
N n;
int * n_member = reinterpret_cast<int*>(&n);
n_member = 5;
did you mean:
N n;
int & n_member = * reinterpret_cast<int*>(&n);
n_member = 5;
?
Gianni Mariani wrote:
Noah Roberts wrote:
...
You still can, but only if you abuse the system:
N n;
int * n_member = reinterpret_cast<int*>(&n);
n_member = 5;
did you mean:
N n;
int & n_member = * reinterpret_cast<int*>(&n);
n_member = 5;
?
but those are the intentional (illegal??) activities of the programmer
..But compiler will complain if the programmer writes
n.n //access denied..
so that means the header files are for compiler..
cheers,
Yogesh Joshi yo******@gmail.com wrote:
Gianni Mariani wrote:
Noah Roberts wrote:
...
You still can, but only if you abuse the system:
>
N n;
int * n_member = reinterpret_cast<int*>(&n);
n_member = 5;
>
did you mean:
N n;
int & n_member = * reinterpret_cast<int*>(&n);
n_member = 5;
?
but those are the intentional (illegal??) activities of the programmer
.But compiler will complain if the programmer writes
n.n //access denied..
so that means the header files are for compiler..
Again, as far as the compiler is concerned, header files don't exist.
Thats why you need to include them into source(s). This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Steven T. Hatton |
last post by:
In the past there have been lengthy discussiions regarding the role of
header files in C++. People have been very adamat about header files
serving as in interface to the implementation. I do...
|
by: pooja |
last post by:
Suppose i have created a class c1 with f1()in c1.cpp
and included this c1.cpp in file1.cpp file , which is also having
main() by giving the statement #include "c1.cpp".
the same i can do by...
|
by: qazmlp |
last post by:
If I include the headers(.h files) like
#include "myHeader.h",
in my implementation file(.C file), then 'myHeader.h' is properly
included. But, when I include it like
#include <myHeader.h>,...
|
by: John Smith |
last post by:
Hi all
What does the group think of the practise of including one header file from
inside another?
I have some legacy code where this has been done, and it creates a
dependency on a module...
|
by: ginnisharma1 |
last post by:
Hi All,
I am very new to C language and I got really big assignment in my
work.I am wondering if anyone can help me.........I need to port
compiler from unix to windows and compiler is written...
|
by: Joseph Geretz |
last post by:
We use a Soap Header to pass a token class (m_Token) back and forth with
authenticated session information. Given the following implementation for
our Logout method, I vastly prefer to simply code...
|
by: vijay |
last post by:
I am trying to learn C and am struck at header file stuff. I have the
following source files in my directory:
header.h
------------
int a_function(int);
library.c
-----------
#include...
|
by: bobby |
last post by:
hi group,
Does the header file size or number in include(s) effect the size of
executable file?
In other world if i chose a large header file and include it with my
source file does it increase...
|
by: Stephen Howe |
last post by:
Hi
Just going over some grey areas in my knowledge in C++:
1) If I have
const int SomeConst = 1;
in a header file, it is global, and it is included in multiple translations
units, but it...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
| |