r1 - 04 Aug 2010 - 18:52:15 - RajMathurYou are here: TWiki >  Main Web > ProgrammingIntroduction > 2010-08-04Wednesday

Topics Covered on Wednesday, 2010-08-04

Objects and Classes

  • Abstract Objects
    • Have attributes (e.g. colour, make, etc.)
    • Have operations (e.g. start, drive, brake, etc.)
  • Abstract Objects can be instantiated
    • Instantiated Abstract Object is an Object
  • In Object-Oriented Programming, an Abstract Object is a Class
    • An instance of a Class is an Object

Sample program

1  // hello.cpp
2  // Print "Hello, world" on the display
3  // Copyright (C) 2010, Raj Mathur
4  #include <iostream>
5  using namespace std;
6  int main(int argc, char *argv[])
7  {
8    cout << "Hello, world" << endl;
9    exit(0);
10 }
  • Lines 1-3 are comments, ignored by the compiler.
  • Line 4 is a preprocessor directive and is replaced by the contents of the file "iostream".
  • Line 5 is required, ignore for now.
  • Line 6 is a function definition. Every function definition consists of the function return type (the range), the name of the function, the arguments to the function and the function body.
  • Every C++ program must have one and only one function named main. Execution begins on the first executable statement of main.
  • Lines 7-10 are the function body.
Edit | WYSIWYG | Attach | Printable | Raw View | Backlinks: Web, All Webs | History: r1 | More topic actions

tip TWiki Tip of the Day
Inline search
To embed a search in a topic, use the %SEARCH{ parameters }% TWiki Variable. The search variable ... Read on Read more

 
Kandalaya
This site is powered by the TWiki collaboration platformCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback