You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
356 B
C++
32 lines
356 B
C++
5 years ago
|
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;
|
||
|
}
|