class with setter and getter : Member method « Class « Visual C++ .NET

Home
Visual C++ .NET
1.2D
2.Class
3.Collections
4.Data Type
5.Database ADO.net
6.Delegate
7.Development
8.File Directory
9.Function
10.Generics
11.GUI Form
12.Language Basics
13.Network
14.Reflection
15.Security
16.Statement
17.Structure
18.Thread
19.XML
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Visual C++ .NET » Class » Member method 
class with setter and getter
 

#include "stdafx.h"
class MyClass
{
   private:
      double pos[3];
      unsigned int a;
      unsigned int b;

   public:
       MyClass() : a(1), b(1)
       {
           pos[00; pos[10; pos[20;
       }

       MyClass(double x, double y, double z, unsigned int a, unsigned int n): a(a), b(n)
       {
          pos[0= x; pos[1= y; pos[2= z;
       }
       unsigned int GetA() { 
          return a; 
       }
       void SetA(unsigned int a) { 
          a = a; 
       }
       unsigned int GetB() { 
          return b; 
       }
       void SetB(unsigned int n) { 
          b = n; 
       }
       double GetPosition(int index) { 
          return pos[index]
       }
       void SetPosition(int index, double value) { 
          pos[index= value; 
       }
};

   
  
Related examples in the same category
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.