A<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://cppe.ru/index.php?action=history&amp;feed=atom&amp;title=C%2B%2B%2FClass%2Fthis</id>
		<title>C++/Class/this - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://cppe.ru/index.php?action=history&amp;feed=atom&amp;title=C%2B%2B%2FClass%2Fthis"/>
		<link rel="alternate" type="text/html" href="http://cppe.ru/index.php?title=C%2B%2B/Class/this&amp;action=history"/>
		<updated>2026-04-10T05:15:36Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://cppe.ru/index.php?title=C%2B%2B/Class/this&amp;diff=1334&amp;oldid=prev</id>
		<title> в 14:21, 25 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://cppe.ru/index.php?title=C%2B%2B/Class/this&amp;diff=1334&amp;oldid=prev"/>
				<updated>2010-05-25T14:21:06Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 14:21, 25 мая 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
			</entry>

	<entry>
		<id>http://cppe.ru/index.php?title=C%2B%2B/Class/this&amp;diff=1335&amp;oldid=prev</id>
		<title>Admin: 1 версия:&amp;#32;Импорт контента...</title>
		<link rel="alternate" type="text/html" href="http://cppe.ru/index.php?title=C%2B%2B/Class/this&amp;diff=1335&amp;oldid=prev"/>
				<updated>2010-05-25T10:25:36Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия: Импорт контента...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==how the this class pointer works==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;  &lt;br /&gt;
#include &amp;lt;iostream&amp;gt;  &lt;br /&gt;
using namespace std;&lt;br /&gt;
class MyClass {  &lt;br /&gt;
  int i;  &lt;br /&gt;
public:  &lt;br /&gt;
  void load_i(int val) { this-&amp;gt;i = val; }&lt;br /&gt;
  int get_i(void) { return this-&amp;gt;i; } &lt;br /&gt;
};  &lt;br /&gt;
main(void){  &lt;br /&gt;
  MyClass o;  &lt;br /&gt;
  o.load_i(100);&lt;br /&gt;
  cout &amp;lt;&amp;lt; o.get_i();&lt;br /&gt;
  return 0;  &lt;br /&gt;
}&lt;br /&gt;
  &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==this points yourself==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;   &lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
#include &amp;lt;string.h&amp;gt;&lt;br /&gt;
using namespace std;&lt;br /&gt;
class SomeClass &lt;br /&gt;
{&lt;br /&gt;
 public:&lt;br /&gt;
   void show_with_this(void) &lt;br /&gt;
   {&lt;br /&gt;
     cout &amp;lt;&amp;lt; &amp;quot;Book: &amp;quot; &amp;lt;&amp;lt; this-&amp;gt;title &amp;lt;&amp;lt; endl;&lt;br /&gt;
     cout &amp;lt;&amp;lt; &amp;quot;Author: &amp;quot; &amp;lt;&amp;lt; this-&amp;gt;author &amp;lt;&amp;lt; endl; &lt;br /&gt;
   };&lt;br /&gt;
   void show_without_this(void) &lt;br /&gt;
   {&lt;br /&gt;
     cout &amp;lt;&amp;lt; &amp;quot;Book: &amp;quot; &amp;lt;&amp;lt; title &amp;lt;&amp;lt; endl;&lt;br /&gt;
     cout &amp;lt;&amp;lt; &amp;quot;Author: &amp;quot; &amp;lt;&amp;lt; author &amp;lt;&amp;lt; endl; &lt;br /&gt;
   };&lt;br /&gt;
   &lt;br /&gt;
   SomeClass(char *title, char *author) &lt;br /&gt;
   {&lt;br /&gt;
     strcpy(SomeClass::title, title);&lt;br /&gt;
     strcpy(SomeClass::author, author);&lt;br /&gt;
   };&lt;br /&gt;
 private:&lt;br /&gt;
   char title[256];&lt;br /&gt;
   char author[256];&lt;br /&gt;
};&lt;br /&gt;
int main(void)&lt;br /&gt;
{&lt;br /&gt;
   SomeClass book(&amp;quot;A&amp;quot;, &amp;quot;B&amp;quot;);&lt;br /&gt;
   book.show_with_this();&lt;br /&gt;
   book.show_without_this();&lt;br /&gt;
}&lt;br /&gt;
  &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Using the this pointer to refer to object members.==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;  &lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
using std::cout;&lt;br /&gt;
using std::endl;&lt;br /&gt;
class Test {&lt;br /&gt;
public:&lt;br /&gt;
   Test( int = 0 );&lt;br /&gt;
   void print() const;&lt;br /&gt;
private:&lt;br /&gt;
   int x;&lt;br /&gt;
}; &lt;br /&gt;
Test::Test( int a ) { x = a; }&lt;br /&gt;
void Test::print() const   &lt;br /&gt;
{&lt;br /&gt;
   cout &amp;lt;&amp;lt; &amp;quot;        x = &amp;quot; &amp;lt;&amp;lt; x&lt;br /&gt;
        &amp;lt;&amp;lt; &amp;quot;\n  this-&amp;gt;x = &amp;quot; &amp;lt;&amp;lt; this-&amp;gt;x&lt;br /&gt;
        &amp;lt;&amp;lt; &amp;quot;\n(*this).x = &amp;quot; &amp;lt;&amp;lt; ( *this ).x &amp;lt;&amp;lt; endl;&lt;br /&gt;
}&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
   Test testObject( 12 );&lt;br /&gt;
   testObject.print();&lt;br /&gt;
   return 0;&lt;br /&gt;
}&lt;br /&gt;
  &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	</feed>