c++类和对象等编程
来源:互联网 发布:深圳程序员招聘网 编辑:程序博客网 时间:2024/05/03 21:39
仅供参考 另外我的程序可能有错误 你如果高兴的话 可以在构造函数中初始变量什么的 这个只是我个人意见 #include <iostream>#include <string>using namespace std;class rech{public:std::int long=0;std::int wide=0;}把这个存放在rech.h中#include <iostream>#include <string>#include "rech.p"using namespace std;class rech_cpp{public:rech_h();~rech_h();void setdata(){cout<<"please set the long of the rechangle"<<endl;cin>>long<<endl;cout<<"please set the wide of the rechangle"<<endl;cin>>wide<<endl;cout<<"long="<<long<<endl;cout<<"wide="<<wide<<endl;}void revisedate(){cout<<"please revise the long of the rechangle"<<endl;cin>>long<<endl;cout<<"please revise the wide of the rechangle"<<endl;cin>>wide<<endl;cout<<"long="<<long<<endl;cout<<"wide="<<wide<<endl;}void printdata(){cout<<"long="<<long<<endl;cout<<"wide="<<wide<<endl;cout<<"perimeter="<<(long+wide)*2<<endl;cout<<"area="<<long*wide<<endl;}}这个存放在rech.cpp中#include <iostream>#include <string>#include "rech.h"#include "rech.cpp"using namespace std;int main(){int x;cout<<"1 setdata "<<endl;cout<<"2 revisedata "<<endl;cout<<"3 printdata "<<endl;cout<<"please chose the menu(1~3)"<<endl;cin>>x<<endl;rech_cpp re;if(x=1)re.setdata();elseif(x=2)re.revisedata();elsere.printdata();return 0;}这个存放在test1.cpp中我已经N久没碰这些东西了
- c++类和对象等编程
- C++:面向对象编程(封装、继承、多态等)
- 类和对象:Objective-C概述、面向对象编程、类和对象、实例变量操作
- c++---类和对象
- C++:类和对象
- 类和对象(C++)
- 【c++】类和对象
- C++:类和对象
- C++:类和对象
- 【C++】类和对象
- objective-c编程语言 第一章 对象,类和消息 第一小节 对象(objects)
- day1: Objective-C概述、面向对象编程、类和对象、实例变量操作
- Perl和C、C++等语言通信的编程方法
- C++类和对象等基本知识整理
- C的对象编程
- [类和对象]-C#OOP
- Objective-C:类和对象
- Objective-C 类和对象
- 1.编写程序:“猫”读入指定文件然后显示;“鼠”读入键盘输入然后写到文件。
- 该怎样解决 为什么c#中打开一个项目不能进行调试
- c++程序编写
- 在SQL中怎么删除一列的语法是什么
- 月光软件站 - 编程文档 - VC语言 - 文档—视窗结构批判
- c++类和对象等编程
- C语言编辑进
- 关于C语言"initgraph"图象函数
- 交换机SPAN技术简介+Cisco配置示例
- 学好C语言要注意哪些啊
- 在C语言中/n放先面和后面有什么不同啊
- 要中文的~ 新手用的c语言编程有哪些软件
- C.K眞的死了嗎
- 关于C语言方面的问题 请高手指教