function and operator overloading are the two most important things in C + + programming language.
mekipun unique function, this function is not much different from other types of functions.
In C + +, a function call is not only determined by the function name, but also
by type and number of actual parameters.
by type and number of actual parameters.
Facilities relating to existing functionality
other in C + + is a template function, operator function, inline function.
other in C + + is a template function, operator function, inline function.
The following is a program of Printing prime numbers between 1-100 by function overloading
#include
#include
#include
#include
class prog
{
friend istream & operator >> ( istream &, prog & );
friend ostream & operator << ( ostream &, prog & );
public:
void id();
prog();
char nama[60];
private:
float m;
float c;
float energi;
};
void prog::id()
{
cout << "Nama Program : ";
cin.getline( nama, 60 );
cout << endl;
}
prog::prog()
{
}
ostream & operator << ( ostream & out, prog & y )
{
{
int i,j,k;
cout<<"bilangan 1-100"<
for (i=2;i<=100;i++){
for (j=2;j<=i/2;j++){
k=i%j;
if (k==0 )break;
}if(k!=0)
cout<<
}
}
return out;
}
int main()
{ cout << "\t\t\t# C++ #\n\n";
char nama[90] =
{
"Cetak Bilangan Prima "
};
cout << "Nama Program :" << nama << endl;
cout << "\n";
prog a;
cout << a;
getch();
return 0;
}
Tidak ada komentar:
Posting Komentar