void AddBookData() //class BookData 객체를 생성, 도서를 등록
{
string title; //제목
string author; //작가
string category; //구분
int price; //가격
int y_num;
int m_num;
int d_num;
cout<<"** 도서 정보를 입력하세요 **"<<endl;
cout<<"제목 : ";
fflush(stdin);
cin>>title;
cout<<"작가 : ";
fflush(stdin);
cin>>author;
cout<<"구분 : ";
fflush(stdin);
cin>>category;
cout<<"가격(원) : ";
fflush(stdin);
cin>>price;
cout<<"입고일 (년, 월 ,일) : ";
fflush(stdin);
cin>>y_num>>m_num>>d_num;
BookList[B_num] = BookData(title, author, category, price, Date(y_num, m_num, d_num)); //class BookData 객체를 생성
B_num++;
cout<<endl;
MainMenu();
}
이 객체가 생성하는 클래스인 bookdata 는
class BookData//도서 클래스(제목, 작가, 구분, 가격, 등록일)
{
string title;
string author;
string category;
int price;
Date initdate;
public:
BookData(string _title = "notitle", string _author = "unknown", string _category = "non", int _price = 0, Date& _initdate = Date(0, 0, 0))
{
title = _title;
author = _author;
category = _category;
price = _price;
initdate = _initdate;
}
void Display()//화면 출력
{
cout.setf(ios_base::left, ios_base::adjustfield);
cout.width(20);
cout<<title<<" ";
cout.width(7);
cout<<author<<" ";
cout.width(7);
cout<<category<<" ";
cout.width(7);
cout<<price<<" ";
initdate.DateDisplay();
cout<<endl;
}
void FDisplay()//파일 출력
{
fout.setf(ios_base::left, ios_base::adjustfield);
fout.width(20);
fout<<title<<" ";
fout.width(7);
fout<<author<<" ";
fout.width(7);
fout<<category<<" ";
fout.width(7);
fout<<price<<" ";
initdate.FDateDisplay();
fout<<endl;
}
string getTitle(){ return title; }
string getAuthor(){ return author; }
string getCategory(){ return category; }
int getPrice(){ return price; }
void setTitle(string _title){ title = _title; }
void setAuthor(string _author){ author = _author; }
void setCategory(string _category){ category = _category; }
void setPrice(int _price){ price = _price; }
};
입니다. 첫번째 객체는 잘 생성되는데 두번째 객체를 생성하려고 하면 걍 쓰레기 값이 자동으로 입력 되는데 뭐가 문제일까요?;;