showthis.cpp
来自「《C/C++程序员实用大全》配套代码,适用初学C++的人员。」· C++ 代码 · 共 38 行
CPP
38 行
#include <iostream.h>
#include <string.h>
class SomeClass
{
public:
void show_with_this(void)
{
cout << "Book: " << this->title << endl;
cout << "Author: " << this->author << endl;
};
void show_without_this(void)
{
cout << "Book: " << title << endl;
cout << "Author: " << author << endl;
};
SomeClass(char *title, char *author)
{
strcpy(SomeClass::title, title);
strcpy(SomeClass::author, author);
};
private:
char title[256];
char author[256];
};
void main(void)
{
SomeClass book("Jamsa's C/C++ Programmer's Bible", "Jamsa and Klander");
book.show_with_this();
book.show_without_this();
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?