本文整理汇总了C++中Cd类的典型用法代码示例。如果您正苦于以下问题:C++ Cd类的具体用法?C++ Cd怎么用?C++ Cd使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Cd类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main() {
Cd c1("Beatles", "Capitol", 14, 35.5);
Classic c2 = Classic("Piano Sonata in B flat, Fantasia in C", "Alfred Brendel", "Philips", 2, 57.17);
Cd *pcd = &c1;
cout << "Using object directly: \n";
c1.report(); // use Cd method
c2.report(); // use Classic method
cout << "Using type cd * pointer to objects:\n";
pcd->report(); // use cd method for cd object
pcd = &c2;
pcd->report(); // use Classic method for classic object
cout << "Calling a function with a Cd reference argument:\n";
bravo(c1);
bravo(c2);
cout << "Testing assignment: ";
Classic copy;
copy = c2;
copy.report();
system("pause");
return 0;
}
示例2: main
int main( int argc, char *argv[] )
{
Cd c1("Beatles", "Capitol", 14, 35.5);
Classic c2 = Classic("Alfred Brendel", "Philips", 2, 57.17,
"Piano Sonata in B flat, Fantasia in C");
Cd * pcd = &c1;
cout << "Using object directly:\n";
c1.Report();
c2.Report();
cout << "Using type cd * poinyer to objects:\n";
pcd->Report();
pcd = &c2;
pcd->Report();
cout << "Calling a function with a Cd reference argument:\n";
Bravo(c1);
Bravo(c2);
cout << "Testing assignment: ";
Classic copy;
copy = c2;
copy.Report();
return 0;
}
示例3: main
int main()
{
Cd c1("Beatles", "Capitol", 14, 35.5);
Classic c2 = Classic("Sonata fortepianowa B-dur, Fantazja C-moll", "Alfred Brendel", "Philips", 2, 57.17);
Cd * pcd = &c1;
std::cout << "Direct usage of the object:\n";
c1.Report(); //uses Cd::Report()
std::cout << std::endl;
c2.Report(); //uses Classic::Report()
std::cout << "\nUsage of pointer to Cd:\n";
pcd->Report(); //Cd::Report
std::cout << std::endl;
pcd = &c2;
pcd->Report(); //Classic::Report()
std::cout << "\nCalling a function with an argument as a reference to Cd type:\n";
Bravo(c1);
std::cout << std::endl;
Bravo(c2);
std::cout << "\nAssignment test:\n";
Classic copy;
copy = c2;
copy.Report();
return 0;
}
示例4: visualizarCds
void SistemaLocadora::visualizarCds()
{
Cd *cd;
for (int i = 0; i < cds.size(); i++)
{
cd = &cds.at(i);
cd->showInfo();
}
}
示例5: main
int main(int argc, const char * argv[])
{
// Brass and Brass Plus banking
Brass Harvey("Harvery Oswald", 123456789, 4183.45);
Brass Helga("Helga Horatio", 987654321, 2592.00);
BrassPlus Helga2(Helga, 500, .125);
Harvey.Deposit(100);
Harvey.ViewAcct();
Harvey.Withdraw(3000);
Harvey.Withdraw(1500);
Harvey.ViewAcct();
Helga2.Brass::Deposit(500);
Helga2.ViewAcct();
Helga2.BrassPlus::Withdraw(2500);
Helga2.ViewAcct();
Helga2.BrassPlus::Withdraw(1000);
Helga2.ViewAcct();
// Cd and Classic
Cd relativity ("Albert Einstein", "Rocafella Records", 10, 28.5);
Classic gravity("Newton", "Vatican Productions", 5, 9.8, "Mass don't matter, Like a virgin");
relativity.Report();
gravity.Report();
// using the function here to call the class function
bravo(relativity);
// when calling gravity it should be called as a Cd and not a Classic object :)
bravo(gravity);
// port and vintage port
Port TawnyGallo("Gallo", "Tawny", 20);
VintagePort OldYeller("Roma", 30, "Old Yeller", 1950);
TawnyGallo.operator+=(5);
TawnyGallo.Show();
TawnyGallo.operator-=(5);
TawnyGallo.Show();
OldYeller.operator+=(5);
OldYeller.Show();
OldYeller.operator-=(5);
OldYeller.Show();
cout << TawnyGallo << endl << OldYeller << endl;
// unfortunately I'm still as yet unsure if I did the work with pointers right
return 0;
}
示例6: Cd
void SistemaLocadora::cadastrarCd()
{
string entradaUsuarioString;
int entradaUsuarioInt;
Cd *cd = new Cd();
cout << "\nDigite o codigo do Cd: ";
cin >> entradaUsuarioInt;
cd->setCodigo(entradaUsuarioInt);
cout << "\nDigite o titulo do Cd: ";
cin.get();
getline(cin, entradaUsuarioString);
cd->setTitulo(entradaUsuarioString);
cout << "\nDigite o total de discos do Cd: ";
cin >> entradaUsuarioInt;
cd->setDiscos(entradaUsuarioInt);
cout << "\nDigite a duracao do Cd: ";
cin >> entradaUsuarioInt;
cd->setDuracao(entradaUsuarioInt);
cout << "\nDigite o numero de faixas do Cd: ";
cin >> entradaUsuarioInt;
cd->setFaixas(entradaUsuarioInt);
cds.insert(cds.begin(), *cd);
}
示例7: main
int main(int nNumberofArgs, char* pszArgs[])
{
//* Variable Declaration
//* Main Code
Cd c1("Beatles", "Capitol", 14, 35.5);
Classic c2 = Classic("Piano Sonata in B flat, Fantasia in C","Alfred Brendel", "Philips", 2, 57.17);
Cd *pcd = &c1;
cout << endl << endl;
cout << "Using object directly:\n";
c1.Report(); // use Cd method
c2.Report(); // use Classic method
cout << endl << endl;
cout << "Using type cd * pointer to objects:\n";
pcd->Report(); // use Cd method for cd object
pcd = &c2;
pcd->Report(); // use Classic method for classic object
cout << endl << endl;
cout << "Calling a function with a Cd reference argument:\n";
Bravo(c1);
Bravo(c2);
cout << "Testing assignment: ";
Classic copy;
copy = c2;
copy.Report();
//* Program End
// - wait until user is ready before terminating program
// - to allow the user to see the program results
cout << endl << endl;
system("PAUSE");
return 0;
}
示例8: sizeof
void SistemaLocadora::arquivoSalvar()
{
ofstream fileSave;
// *** GRAVACAO CDS ************
if (cds.size() > 0)
{
fileSave.open(filenameCds, ios::binary);
int cdsSize = (int)cds.size();
fileSave.write((char*)&cdsSize, sizeof(unsigned int));
Cd *cd = NULL;
for (int i = 0; i < cds.size(); i++)
{
cd = &cds.at(i);
int codigo = (int)cd->getCodigo();
fileSave.write((char*)&codigo, sizeof(unsigned int));
string titulo = cd->getTitulo();
fileSave.write((char*)titulo.c_str(), 100 * sizeof(char));
int discos = (int)cd->getDiscos();
fileSave.write((char*)&discos, sizeof(unsigned int));
int duracao = (int)cd->getDuracao();
fileSave.write((char*)&duracao, sizeof(unsigned int));
int faixas = (int)cd->getFaixas();
fileSave.write((char*)&faixas, sizeof(unsigned int));
}
}
fileSave.close();
// *** GRAVACAO DVD ************
if (dvds.size() > 0)
{
fileSave.open(filenameDvds, ios::binary);
int dvdsSize = (int)dvds.size();
fileSave.write((char*)&dvdsSize, sizeof(unsigned int));
Dvd *dvd = NULL;
for (int i = 0; i < dvds.size(); i++)
{
dvd = &dvds.at(i);
int codigo = (int)dvd->getCodigo();
fileSave.write((char*)&codigo, sizeof(unsigned int));
string titulo = dvd->getTitulo();
fileSave.write((char*)titulo.c_str(), 100 * sizeof(char));
int discos = (int)dvd->getDiscos();
fileSave.write((char*)&discos, sizeof(unsigned int));
int duracao = (int)dvd->getDuracao();
fileSave.write((char*)&duracao, sizeof(unsigned int));
int regiao = (int)dvd->getRegiao();
fileSave.write((char*)®iao, sizeof(unsigned int));
string legendas = dvd->getLegendas();
fileSave.write((char*)legendas.c_str(), 100 * sizeof(char));
}
}
fileSave.close();
// *** GRAVACAO LIVRO ***********
if
}
示例9: Bravo
void Bravo(const Cd & disk)
{
disk.Report();
}
示例10: bravo
void bravo(const Cd & disk) {
disk.report();
}
示例11: Bravo
void Bravo(const Cd & cd)
{
cd.Report();
}