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

📄 main.cpp

📁 斯坦福Energy211/CME211课《c++编程——地球科学科学家和工程师》的课件
💻 CPP
字号:
#include <iostream>#include "employee.h"#include "hourly.h"#include "salaried.h"using namespace std;int main() {		// Dynamically create a new Hourly object.	// The new operator returns a pointer to the object.	Hourly *ph = new Hourly( "James Lambers", 		"010-10-1010", 20.0, 40 );		// Now we do the same with a Salaried object, except	// we use a smart pointer, which we don't have to 	// remember to delete	auto_ptr<Salaried> ps(new Salaried( "Margot Gerritsen",		"987-65-4321", 7000.0 ));			// We can't create an Employee object, but we can	// have a pointer to an Employee object	Employee *pe = ph;		// Output the Hourly object, accessing it through	// the Employee pointer	cout << "First Employee:" << endl;	cout << "===============" << endl;	cout << *pe;	cout << endl;		// Then output the Salaried object	cout << "Second Employee:" << endl;	cout << "================" << endl;	cout << *ps;				// The Hourly object is not stored in a smart pointer,	// so we have to delete it.  We can access it through	// the Employee pointer, and because the Employee	// destructor is virtual, the Hourly destructor will	// be called too	delete pe;		return 0;}

⌨️ 快捷键说明

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