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_Tutorial%2FClass%2Faccessor_functions</id>
		<title>C++ Tutorial/Class/accessor functions - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://cppe.ru/index.php?action=history&amp;feed=atom&amp;title=C%2B%2B_Tutorial%2FClass%2Faccessor_functions"/>
		<link rel="alternate" type="text/html" href="http://cppe.ru/index.php?title=C%2B%2B_Tutorial/Class/accessor_functions&amp;action=history"/>
		<updated>2026-04-04T03:53:07Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://cppe.ru/index.php?title=C%2B%2B_Tutorial/Class/accessor_functions&amp;diff=2311&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_Tutorial/Class/accessor_functions&amp;diff=2311&amp;oldid=prev"/>
				<updated>2010-05-25T14:21:17Z</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_Tutorial/Class/accessor_functions&amp;diff=2312&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_Tutorial/Class/accessor_functions&amp;diff=2312&amp;oldid=prev"/>
				<updated>2010-05-25T10:29:25Z</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;==Accessor functions==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
 class MyClass {&lt;br /&gt;
 public:                     // begin public section&lt;br /&gt;
     int getInt();           // accessor function&lt;br /&gt;
     void setint (int age);  // accessor function&lt;br /&gt;
     void display();         // general function&lt;br /&gt;
 private:                    // begin private section&lt;br /&gt;
     int itsAge;             // member variable&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 int MyClass::getInt()&lt;br /&gt;
 {&lt;br /&gt;
     return itsAge;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void MyClass::setint(int age)&lt;br /&gt;
 {&lt;br /&gt;
     itsAge = age;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void MyClass::display()&lt;br /&gt;
 {&lt;br /&gt;
     std::cout &amp;lt;&amp;lt; &amp;quot;display.\n&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 int main()&lt;br /&gt;
 {&lt;br /&gt;
     MyClass obj;&lt;br /&gt;
     obj.setint(5);&lt;br /&gt;
     obj.display();&lt;br /&gt;
     std::cout &amp;lt;&amp;lt; obj.getInt() &amp;lt;&amp;lt; &amp;quot; years old.\n&amp;quot;;&lt;br /&gt;
     obj.display();&lt;br /&gt;
     return 0;&lt;br /&gt;
 }&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;display.&lt;br /&gt;
5 years old.&lt;br /&gt;
display.&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Access private data through accessor functions.==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;#include &amp;lt;iostream&amp;gt; &lt;br /&gt;
#include &amp;lt;cstring&amp;gt; &lt;br /&gt;
using namespace std; &lt;br /&gt;
 &lt;br /&gt;
class Shape { &lt;br /&gt;
  // private &lt;br /&gt;
  double width; &lt;br /&gt;
  double height; &lt;br /&gt;
public: &lt;br /&gt;
 &lt;br /&gt;
  void display() { &lt;br /&gt;
    cout &amp;lt;&amp;lt; &amp;quot;Width and height are &amp;quot; &amp;lt;&amp;lt; width &amp;lt;&amp;lt; &amp;quot; and &amp;quot; &amp;lt;&amp;lt; height &amp;lt;&amp;lt; &amp;quot;\n&amp;quot;; &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
  // accessor functions &lt;br /&gt;
  double getWidth() { return width; } &lt;br /&gt;
  double getHeight() { return height; } &lt;br /&gt;
  void setWidth(double w) { width = w; } &lt;br /&gt;
  void setHeight(double h) { height = h; } &lt;br /&gt;
}; &lt;br /&gt;
 &lt;br /&gt;
// Triangle is derived from Shape. &lt;br /&gt;
class Triangle : public Shape { &lt;br /&gt;
public: &lt;br /&gt;
  char style[20]; &lt;br /&gt;
   &lt;br /&gt;
  double area() { &lt;br /&gt;
    return getWidth() * getHeight() / 2; &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
  void showStyle() { &lt;br /&gt;
    cout &amp;lt;&amp;lt; &amp;quot;Triangle is &amp;quot; &amp;lt;&amp;lt; style &amp;lt;&amp;lt; &amp;quot;\n&amp;quot;; &lt;br /&gt;
  } &lt;br /&gt;
}; &lt;br /&gt;
 &lt;br /&gt;
int main() { &lt;br /&gt;
  Triangle t1; &lt;br /&gt;
  Triangle t2; &lt;br /&gt;
 &lt;br /&gt;
  t1.setWidth(4.0); &lt;br /&gt;
  t1.setHeight(4.0); &lt;br /&gt;
  strcpy(t1.style, &amp;quot;isosceles&amp;quot;); &lt;br /&gt;
 &lt;br /&gt;
  t2.setWidth(8.0); &lt;br /&gt;
  t2.setHeight(12.0); &lt;br /&gt;
  strcpy(t2.style, &amp;quot;right&amp;quot;); &lt;br /&gt;
 &lt;br /&gt;
  t1.showStyle(); &lt;br /&gt;
  t1.display(); &lt;br /&gt;
  cout &amp;lt;&amp;lt; &amp;quot;Area is &amp;quot; &amp;lt;&amp;lt; t1.area() &amp;lt;&amp;lt; &amp;quot;\n&amp;quot;; &lt;br /&gt;
 &lt;br /&gt;
  t2.showStyle(); &lt;br /&gt;
  t2.display(); &lt;br /&gt;
  cout &amp;lt;&amp;lt; &amp;quot;Area is &amp;quot; &amp;lt;&amp;lt; t2.area() &amp;lt;&amp;lt; &amp;quot;\n&amp;quot;; &lt;br /&gt;
 &lt;br /&gt;
  return 0; &lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;Triangle is isosceles&lt;br /&gt;
Width and height are 4 and 4&lt;br /&gt;
Area is 8&lt;br /&gt;
Triangle is right&lt;br /&gt;
Width and height are 8 and 12&lt;br /&gt;
Area is 48&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	</feed>