Procedure-Oriented and Object-Oriented Programming— A Tiny Example in c++
Here are two tiny program based on c++ for distinguishing the procedure oriented programming and objected oriented programming. The example problem is a simple Number Determination problem (ND).
ND problem : Giving a integer number, determinate it is odd or not.
本文给出两种思路,分别是面向对象和面向过程,来解决一个简单的 判断奇偶 的问题(ND):给定一个整数,判断它是奇数还是偶数。
For procedure-oriented-programming
int main(void)
{
int num=0;
cout<<"Input a interger number: " ;
cin>>num;
if (num%2 == 0)