android数据存储之外部存储(External Storage)
#include "HandCake.h" //手抓饼 HandCake::HandCake() { this->price=10; this->name="手抓饼"; } HandCake::~HandCake(void) { } int HandCake::GetPrice() { return 10; } string HandCake::GetName() { return name; }
#include "Ham.h" Ham::Ham(void) { } Ham::Ham(HandCake *cake) { //this->cake=cake; int p=cake->price; this->name=cake->name+"加火腿"; this->price=cake->price+1; } Ham::~Ham(void) { } string Ham::GetName() { return this->name; } int Ham::GetPrice() { return this->price; }
// Decoration.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include "HandCake.h" #include "Ham.h" #include <iostream> #include "vld.h" using namespace std; int _tmain(int argc, _TCHAR* argv[]) { HandCake *cake=new HandCake(); Ham *HamHandCake1=new Ham(cake); std::cout<<HamHandCake1->GetName()<<HamHandCake1->GetPrice()<<"元"<<endl; Ham *HamHandCake2=new Ham(HamHandCake1); std::cout<<HamHandCake2->GetName()<<HamHandCake2->GetPrice()<<"元"<<endl; getchar(); delete cake; delete HamHandCake1; delete HamHandCake2; return 0; }
运行结果:
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。