Friend function
narendra
c_cpp
a year ago
255 B
7
Indexable
#include <iostream>
using namespace std;
class A{
int x ;
public:
A (int y ){
x = y;
}
friend void print(A &obj );
};
void print (A &obj){
cout<<obj.x<<endl;
}
int main(){
A obj(5);
//cout<<obj.x<<endl;
print (obj);
return 0;
}Editor is loading...
Leave a Comment