Struct and class have the same writing. Declaration of class and struct has members with access to the public unless otherwise noted. C + + does not distinguish between class name and name tags, at least from the standpoint of programmer and still receive the declaration structure. Compatibility C + + is not limited to the difference in the name of class distinction type name because C + + still requires the definition of type POD (Plain Old Data). C + + defines a POD type as the object of a class that has no userdefined constructors, protected or private members, does not have a base class and has no virtual functions.
See the code :
# include <cstdlib>
# include <iostream>
using namespace std;
class Triangle { // class program
public:
int print ();
private:
int i, j, n;
};
int triangle:: print ()
court <<"Enter the number of iteration =";
cin>> n;
for (i = 1; i <= n; i + +)
{
for (j = 1; j <= i, j + +)
court <<"*";
court <<"\ n";
}
}
int main (int argc, char * argv []) // main program
{
a triangle;
a.cetak ();
system ("PAUSE");
return EXIT_SUCCESS;
}
0 comments on Class Sample In C++ Language :
Post a Comment and Don't Spam!
Dont Spam please