⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 class1.cpp

📁 Since the field of object oriented programming is probably new to you, you will find that there is a
💻 CPP
字号:
                                // Chapter 2 - Program 3 - CLASS1.CPP
#include <iostream.h>

class animal 
{
public:
   int weight;
   int feet;
};

int main()
{
animal dog1, dog2, chicken;
animal cat1;
class animal cat2;

   dog1.weight = 15;
   dog2.weight = 37;
   chicken.weight = 3;

   dog1.feet = 4;
   dog2.feet = 4;
   chicken.feet = 2;

   cout << "The weight of dog1 is " << dog1.weight << "\n";
   cout << "The weight of dog2 is " << dog2.weight << "\n";
   cout << "The weight of chicken is " << chicken.weight << "\n";

   return 0;
}




// Result of execution
//
// The weight of dog1 is 15
// The weight of dog2 is 37
// The weight of chicken is 3

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -