c++题目 求解释

来源:百度知道 编辑:UC知道 时间:2024/06/08 15:42:16
#include <iostream.h> // We are talking C++
#include <stdlib.h> // for exit()
#include <string.h> // for strcpy()

//==============================================================================
// Prototypes

//==============================================================================
// Global vars declarations
const int STKS = 4 ;

//==============================================================================
// class declare in include directive
#include "EXER_30_ClassDef.h"

//==============================================================================
void main(void)
{
int flag = 1 ;
Stock my_stock ;

// The next three lines are C++ way to specify format with desired precision
cout.precision(2) ;
cout.setf(ios::fixed , ios::floatfield) ;
cout.setf(ios::showpoint) ;

while( flag != 0 )
{

#include <iostream.h> //这是一个C++程序,标准C++不用.h,所以改为#include <isotream>
#include <stdlib.h> //可以将这行去掉,也可以将这一行应改为#include <cstdlib>,
#include <string.h> // 这行改为#include <string>

const int STKS = 4 ; //全局变量

//包含的头文件,下面有一个Stock类的声明就在这个文件里,可你没有给出
#include "EXER_30_ClassDef.h"

void main(void) //这种写法完全错误,在C++中应该写为int main()
{
int flag = 1 ; //标志,下文有
Stock my_stock ; //声明一个my_stock的类
cout.precision(2) ; //输出精确度为2
cout.setf(ios::fixed , ios::floatfield) ;//标准设置
cout.setf(ios::showpoint) ; //显示浮点数后面的小数点

while( flag != 0 ) //这一步将会执行因为flag==1,想退出在循环里输入0
{
cout << "\n...EXER_30 running. Enter integer flag (0 to get out): " ;
cin >> flag ;
cout << "flag entered = " << flag << "\n" ;
}
//Proto: Stock(const char *co , int n , double pr) ;
//调用copy构