card.cpp
来自「此文件可以能帮你求体积」· C++ 代码 · 共 35 行
CPP
35 行
// 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 + =
减小字号Ctrl + -
显示快捷键?