programming-examples/c++/Others/Demonstrates the use of a simple C++ class.cpp

32 lines
356 B
C++
Raw Normal View History

2019-11-15 12:59:38 +01:00
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;
}