Untitled

 avatar
unknown
c_cpp
2 years ago
728 B
5
Indexable
#include <iostream> 
 
using namespace std; 
 
class Test{ 
int A; 
friend void Set_Param(Test& S, int P); 
friend class Test_B; 
public: 
Test(){ 
 
} 
Test(int P){ 
A = P; 
} 
virtual void Show(){ 
cout « A « endl; 
} 
}; 
 
class Test_B{ 
Test One; 
public: 
void Change(){ 
One.A = 25; 
} 
void Show(){ 
cout « One.A « endl; 
} 
}; 
 
class Test_C : public Test{ 
 double D; 
 public: 
 virtual void Show(){ 
 
 } 
 void Show(int a, double b, string c){ 
 cout « a « b « c « endl; 
} 
}; 
 
void Set_Param(Test& S, int P){ 
S.A = P; 
} 
 
int main() 
{ 
Test first(5); 
Test_C thirt; 
thirt.Show(15, 25.2, "fsdf"); 
Set_Param(first, 15); 
first.Show(); 
Test_B second; 
second.Change(); 
second.Show(); 
return 0; 
}
Editor is loading...
Leave a Comment