bobj格式和mod格式
时间: 2023-10-25 17:08:16 浏览: 40
BOBJ格式和MOD格式都是文件格式的一种,但是用途不同。
BOBJ格式通常指的是SAP BusinessObjects软件的报表文件格式,用于存储报表的数据、图表、格式及其它信息,可以通过SAP BusinessObjects软件打开和编辑。BOBJ格式的文件扩展名通常是.rpt。
MOD格式通常指的是模型文件格式,用于存储3D模型的数据、结构、纹理等信息,可以通过各种3D建模软件打开和编辑,如3DS Max、Maya、Blender等。MOD格式的文件扩展名通常是.mod。
总的来说,BOBJ格式和MOD格式是两种不同的文件格式,用于不同的应用场景。
相关问题
用C++写代码:重新编写下述程序,使函数 Leisure()成为类 Car 和类 Boat的函数。作为重新编程在类Car 和类 Boat中,增加函数 get()。#include<iostream> using namespace std; class Boat; class Car { public: Car(int j){size = j;} friend int Leisure(int time, Car& aobj, Boat& bobj); protected: int size; }; class Boat { public: Boat(int j){size = j;} friend int Leisure(int time, Car& aobj, Boat& bobj); protected: int size; }; int Leisure(int time, Car& aobj, Boat& bobj) { return time * aobj.size * bobj.size; } int main() { Car cl(2); Boat bl(3); int time = 4; cout<<Leisure(time,cl,bl); }
以下是重新编写后的代码:
```c++
#include<iostream>
using namespace std;
class Boat;
class Car {
public:
Car(int j){size = j;}
int get() {return size;}
friend int Leisure(int time, Car& aobj, Boat& bobj);
protected:
int size;
};
class Boat {
public:
Boat(int j){size = j;}
int get() {return size;}
friend int Leisure(int time, Car& aobj, Boat& bobj);
protected:
int size;
};
int Leisure(int time, Car& aobj, Boat& bobj) {
return time * aobj.get() * bobj.get();
}
int main() {
Car cl(2);
Boat bl(3);
int time = 4;
cout<<Leisure(time,cl,bl);
}
```
在这个代码中,我们将Leisure函数变成了Car和Boat类的成员函数,并且增加了get函数来获取size属性的值。在Leisure函数中,我们调用了Car和Boat的get函数来获取它们的size属性,然后进行计算并返回结果。最后在main函数中,我们创建了一个Car对象cl和一个Boat对象bl,并将它们作为参数传递给Leisure函数来计算。
分析这段代码#include <iostream> using namespace std; class Base{ protected: int n; public: Base (int m){ n=m++; } virtual void g1(){cout<<"Base::g1()..."<<n<<endl; g4();} virtual void g2(){cout<<"Base::g2()..."<<++n<<endl;g3();} void g3(){cout<<"Base::g3()..."<<++n<<endl; g4();} void g4(){cout<<"Base::g4()..."<<++n<<endl;} }; class Derive:public Base{ int j; public: Derive(int n1,int n2):Base(n1){ j=n2; } void g1(){cout<<"Deri::g1()..."<<++n<<endl;g2();} void g3(){cout<<"Deri::g2()..."<<++n<<endl;g4();} }; int main(){ Derive Dobj(1,0); Base Bobj=Dobj; Bobj.g1(); cout<<" "<<endl; Base *bp=&Dobj; bp->g1(); cout<<" "<<endl; Base &bobj2=Dobj; bobj2.g1(); cout<<" "<<endl; Dobj.g1(); return 0; }
这段代码定义了一个基类 Base 和一个派生类 Derive。Base 类中有四个成员函数 g1、g2、g3、g4,其中 g1 和 g3 是虚函数。Derive 类继承自 Base 类,新增了一个成员变量 j,并重写了 g1 和 g3 函数。
在主函数中,首先创建了一个 Derive 对象 Dobj,然后通过对象切片将其转换为 Base 对象 Bobj,并调用 Bobj 的虚函数 g1,输出 "Base::g1()...1" 和 "Base::g4()...2"。之后又定义了一个指向 Derive 对象的 Base 指针 bp,调用它的虚函数 g1,输出 "Deri::g1()...1"、"Base::g2()...3" 和 "Deri::g2()...4"。接着又定义了一个 Base 引用 bobj2,将其指向 Dobj,并调用它的虚函数 g1,输出 "Deri::g1()...5"、"Base::g2()...6" 和 "Deri::g2()...7"。最后,直接调用 Dobj 的虚函数 g1,输出 "Deri::g1()...8"、"Base::g2()...9" 和 "Deri::g2()...10"。
可以看出,这段代码主要演示了对象切片和多态的使用。其中,对象切片是指将一个派生类对象赋值给一个基类对象的过程,这样就只保留了基类的部分属性和方法,派生类独有的属性和方法被丢失了。多态是指同一函数在不同情况下采取不同的行为方式,这里通过虚函数的重写和动态绑定实现了多态。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)