showthis.cpp
来自「C/C++使用技巧1001例一书的配套代码」· C++ 代码 · 共 32 行
CPP
32 行
#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 1001 C/C++ Tips", "Jamsa");
book.show_with_this();
book.show_without_this();
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?