classes example : class definition « Class « C++ Tutorial

Home
C++ Tutorial
1.Language Basics
2.Data Types
3.Operators statements
4.Array
5.Development
6.Exceptions
7.Function
8.Structure
9.Class
10.Operator Overloading
11.Pointer
12.File Stream
13.template
14.STL Introduction
15.string
16.vector
17.list
18.bitset
19.set multiset
20.valarray
21.queue stack
22.deque
23.map multimap
24.STL Algorithms Modifying sequence operations
25.STL Algorithms Non modifying sequence operations
26.STL Algorithms Binary search
27.STL Algorithms Sorting
28.STL Algorithms Merge
29.STL Algorithms Min Max
30.STL Algorithms Iterator
31.STL Algorithms Heap
32.STL Algorithms Helper
C / ANSI-C
C Tutorial
C++
Visual C++ .NET
C++ Tutorial » Class » class definition 
9.1.2.classes example
#include <iostream>
#include <stdio.h>
using namespace std;

class Rectangle {
    int x, y;
  public:
    void set_values (int,int);
    int area (void) {return (x*y);}
};

void Rectangle::set_values (int a, int b) {
  x = a;
  y = b;
}

int main () {
  Rectangle rect;
  rect.set_values (3,4);
  cout << "area: " << rect.area();
  return 0;
}
area: 12"
9.1.class definition
9.1.1.Define your first class
9.1.2.classes example
9.1.3.Create an object from a Class and call its function
9.1.4.Define a class with a member function that takes a parameter
9.1.5.Define class with a data member and member functions to set and get its value
9.1.6.Instantiating multiple objects of the class using its constructor
9.1.7.Define class to record time
9.1.8.Class objects can be assigned to each other using default memberwise assignment
9.1.9.Local Classes: A class may be defined within a function
9.1.10.containership with employees and degrees
9.1.11.Inner class
9.1.12.Friend Classes
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.