lasd/teoria/friendFunction.cpp

20 lines
378 B
C++
Raw Normal View History

2021-03-19 11:30:28 +01:00
#include<iostream>
using namespace std;
struct Studente{
friend void printSecureNumber(Studente); // posso mettere questa linea ovunque all'interno della struct
string nome;
string cognome;
private:
int secureNumber = 999;
};
void printSecureNumber(Studente s){
cout<<s.secureNumber<<endl;
}
int main(){
Studente st;
printSecureNumber(st);
return 0;
}