⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 card.cpp

📁 《C++程序设计习题及解答》配套代码VC版
💻 CPP
字号:
// Card.cpp: implementation of the Card class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "Card.h"
#include <string.h>
#include <iostream.h>

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

Card::Card( char* t, char* name, int num )
{
	cout << "sizeof(title) is " << sizeof(title) << endl;
	cout << "sizeof(*title) is " << sizeof(*title) << endl;

	strncpy( title, t, sizeof( title ) );
	title[ sizeof(title)/sizeof(*title) - 1 ] = '\0';

	strncpy( author, name, sizeof( author ) );
	author[ sizeof(author)/sizeof(*author) -1 ] = '\0';

	number = num;
}

void Card::Show()
{
	cout << "\nTitle:" << title << endl;
	cout << "Author:" << author << endl;
	cout << "Number on hand:" << number << endl;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -