class example of C++
#include <iostream>
using namespace std;
class Rectangle {
int width, height;
public:
void set_values (int,int);
int area() {return width*height;}
};
void Rectangle::set_values (int x, int y) {
width = x;
height = y;
}
int main () {
Rectangle rect;
rect.set_values (3,4);
cout << "area: " << rect.area();
return 0;
}
using namespace std;
class Rectangle {
int width, height;
public:
void set_values (int,int);
int area() {return width*height;}
};
void Rectangle::set_values (int x, int y) {
width = x;
height = y;
}
int main () {
Rectangle rect;
rect.set_values (3,4);
cout << "area: " << rect.area();
return 0;
}
想要看到更多学习笔记、考试复习资料、面试准备资料?
想要看到IBM工作时期的技术积累和国外初创公司的经验总结?
敬请关注:
[CSDN](https://blog.csdn.net/u013152895)
[简书](https://www.jianshu.com/u/594a3de3852d)
[博客园](https://www.cnblogs.com/vigorz/)
[51Testing](http://www.51testing.com/?15263728)