本文整理汇总了C++中Star::AppendToFile方法的典型用法代码示例。如果您正苦于以下问题:C++ Star::AppendToFile方法的具体用法?C++ Star::AppendToFile怎么用?C++ Star::AppendToFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Star
的用法示例。
在下文中一共展示了Star::AppendToFile方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addStar
void addStar()
{
char name[NAME_SZ] = "";
long temp = 0;
double lumin = 0, mass = 0, radius = 0;
Star *newStar;
if(strcmp(Star::filePath_, "") == 0) //if no file is open, do nothing.
{
cout << "No file to write to, please load a file.\n";
return;
}
cout << "Please enter the following information: \nName: ";
cin >> name;
newStar = new Star(name); //instantiate star with name
if(newStar == 0) //Abort if memory allocation fails.
{
cout << "Memory allocation failed.\n";
return;
}
cout << "Temperature: ";
cin >> temp;
newStar->SetTemperature(temp);
cout << "Luminosity: ";
cin >> lumin;
newStar->SetLuminosity(lumin);
cout << "Mass: ";
cin >> mass;
newStar->SetMass(mass);
cout << "Radius: ";
cin >> radius;
newStar->SetRadius(radius);
linkList.AddLinkToBack(newStar); //add star to linked list
newStar->AppendToFile();
}