Initial commit
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
Demonstrates the use of a simple C++ class
|
||||
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
class cl {
|
||||
int i; // private by default
|
||||
public:
|
||||
int get_i();
|
||||
void put_i(int j);
|
||||
};
|
||||
|
||||
int cl::get_i()
|
||||
{
|
||||
return i;
|
||||
}
|
||||
|
||||
void cl::put_i(int j)
|
||||
{
|
||||
i = j;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
cl s;
|
||||
|
||||
s.put_i(10);
|
||||
cout << s.get_i() <<endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user