0
CPP:3 problem of Header-file and source-file
First of all,How to assess private or protected functions and variables that have declared in header-file via source-file? Then what is the difference between source-file and main-file?Are there some special connection between HF and SF? And what is Friend-function or Friend-class,how to declare?
1 Respuesta
+ 1
Too many questions to answer at once :
1- you can't access any data if it is private from outside a class or struct. If it's protected then only the class or struct or it's friends can access the data
2. Main file is that specific source file which have the main function. There can only be 1 main file in any project
3.hf is only known and linked to those source files which in which Hf is defined.
4.
If you declare a class friend of another then that declared class is allowed to use public and protected data of the main class.
Same as a friend functions
https://code.sololearn.com/c3c0wGdA4Bof/?ref=app