#include<iostream>
#include"string.h"
#pragma warning(disable:4996)//解决strcpy()编译不通过问题、、、、、、、、、、、、加上这句
using namespace std;
using std::string;
class Book{
private:
char m_tile[30];
char m_author[30];
double m_price;
public:
Book(){}
Book(char title[], char author[], double price)
{
strcpy((char*)(m_tile),(char*)(title));
strcpy((char*)(m_author),(char*)(author));
m_price = price;
}
char *getTitle()
{
return m_tile;
}
char *getAuthor()
{
return m_author;
}
double getPrice()
{
return m_price;
}
};
int main()
{
Book book("vc++","明日科技",56.9);
cout << "书名:" << book.getTitle() << endl;
cout << "作者:" << book.getAuthor() << endl;
cout << "价格:" << book.getPrice() << endl;
system("pause");
return 0;
}
#include"string.h"
#pragma warning(disable:4996)//解决strcpy()编译不通过问题、、、、、、、、、、、、加上这句
using namespace std;
using std::string;
class Book{
private:
char m_tile[30];
char m_author[30];
double m_price;
public:
Book(){}
Book(char title[], char author[], double price)
{
strcpy((char*)(m_tile),(char*)(title));
strcpy((char*)(m_author),(char*)(author));
m_price = price;
}
char *getTitle()
{
return m_tile;
}
char *getAuthor()
{
return m_author;
}
double getPrice()
{
return m_price;
}
};
int main()
{
Book book("vc++","明日科技",56.9);
cout << "书名:" << book.getTitle() << endl;
cout << "作者:" << book.getAuthor() << endl;
cout << "价格:" << book.getPrice() << endl;
system("pause");
return 0;
}