基于上次作业
定义一个图书类,包含图书名字、价格、数量,将名字修改为指针(char *)类型,使用初始化列表完成图书信息初始化。
#include <iostream>
#include <cstdlib>
#include <cstring>
using namespace std;
class Book
{
public:
Book(string name,float price ,int count)
{
m_name=name;
m_price=price;
this->m_count=count;
}
void print()
{
cout<<"名字:"<<m_name<<",价格:"<<m_price<<",数量:"<<m_count<<endl;
}
private:
string m_name;
float m_price;
int m_count;
};
int main()
{
Book book("hhh",2.5,10);
book.print();
return 0;
}