Unix ProgrammingC++ and QtFebruary 2010
C++✤   Object Orientated Language    ✤   Adds to the C Language    ✤   Pre-dates Java and C#    ✤   Fully Compiled    ✤   ...
C++✤   Points of interest    ✤   Multiple Inheritance    ✤   Operator overloading    ✤   Templates    ✤   Strings
C++✤   Things you might miss    ✤   No garbage collection - manual memory management    ✤   No collections        ✤   You ...
Qt✤   Cross platform GUI framework    ✤   Compatible at source level✤   C++ based Object Orientated Framework    ✤   With ...
Part A - Anatomy of a C++ ProgramThe classclass declaration (header file)   class implementation (cpp file)class MyClass    ...
Part A - Anatomy of a C++ ProgramThe classclass declaration (header file)   class implementation (cpp file)class MyClass    ...
Part A - Anatomy of a C++ ProgramThe classclass declaration (header file)   class implementation (cpp file)class MyClass    ...
Part A - Anatomy of a C++ ProgramThe classclass declaration (header file)   class implementation (cpp file)class MyClass    ...
Part A - Anatomy of a C++ ProgramThe classclass declaration (header file)   class implementation (cpp file)class MyClass    ...
Part A - Anatomy of a C++ ProgramThe classclass declaration (header file)   class implementation (cpp file)class MyClass    ...
Part A - Anatomy of a C++ ProgramThe classclass declaration (header file)   class implementation (cpp file)class MyClass    ...
Part A - Anatomy of a C++ ProgramThe classclass declaration (header file)   class implementation (cpp file)class MyClass    ...
Part A - Anatomy of a C++ ProgramThe classclass declaration (header file)   class implementation (cpp file)class MyClass    ...
Part A - Anatomy of a C++ ProgramThe classclass declaration (header file)   class implementation (cpp file)class MyClass    ...
Part A - Anatomy of a C++ ProgramThe classclass declaration (header file)   class implementation (cpp file)class MyClass    ...
Part A - Anatomy of a C++ ProgramThe classclass declaration (header file)   class implementation (cpp file)class MyClass    ...
Part A - Anatomy of a C++ ProgramThe classclass declaration (header file)   class implementation (cpp file)class MyClass    ...
Part A - Anatomy of a C++ ProgramThe classclass declaration (header file)   class implementation (cpp file)class MyClass    ...
Part A - Anatomy of a C++ ProgramThe classclass declaration (header file)   class implementation (cpp file)class MyClass    ...
Part A - Anatomy of a C++ ProgramThe classclass declaration (header file)   class implementation (cpp file)class MyClass    ...
Instantiating objects✤   Two options    ✤   MyClass a(18);    ✤   a.setAge(21);✤   Pointer type (heap only)    ✤   MyClass...
Strings✤   C++ has a standard string library    ✤   #include <string>    ✤   Create strings:        ✤   std::string s = "H...
Videos✤   See videos on the module site    ✤   C++    ✤   Qt
Upcoming SlideShare
Loading in …5
×

87fg8df7g8df7g87sd7f8s7df8sdf7

871 views

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
871
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • 87fg8df7g8df7g87sd7f8s7df8sdf7

    1. 1. Unix ProgrammingC++ and QtFebruary 2010
    2. 2. C++✤ Object Orientated Language ✤ Adds to the C Language ✤ Pre-dates Java and C# ✤ Fully Compiled ✤ Standard Libraries (such as strings)
    3. 3. C++✤ Points of interest ✤ Multiple Inheritance ✤ Operator overloading ✤ Templates ✤ Strings
    4. 4. C++✤ Things you might miss ✤ No garbage collection - manual memory management ✤ No collections ✤ You can use the Standard Template Library (STL)
    5. 5. Qt✤ Cross platform GUI framework ✤ Compatible at source level✤ C++ based Object Orientated Framework ✤ With some (rather good) Qt extensions ✤ Lots of useful components (strings, networking, Variant data types etc..)✤ Available on Linux, Mac OS, Symbian, MS Windows,........
    6. 6. Part A - Anatomy of a C++ ProgramThe classclass declaration (header file) class implementation (cpp file)class MyClass #include "myclass.h"{private: MyClass::MyClass() { int age; MyClass(0); } void anotherBirthday() { age++; MyClass::MyClass(int initialValue) { } this->setAge(initialValue); }public: MyClass(); MyClass::~MyClass() { MyClass(int initialValue); age = 0; } ~MyClass(); int getAge() { void MyClass::setAge(int v) { return age; if (age == v) return; } age = v; void setAge(int v); }};
    7. 7. Part A - Anatomy of a C++ ProgramThe classclass declaration (header file) class implementation (cpp file)class MyClass #include "myclass.h"{private: MyClass::MyClass() { int age; MyClass(0); } void anotherBirthday() { age++; MyClass::MyClass(int initialValue) { } this->setAge(initialValue); }public: MyClass(); MyClass::~MyClass() { MyClass(int initialValue); age = 0; } ~MyClass(); int getAge() { void MyClass::setAge(int v) { return age; if (age == v) return; } age = v; void setAge(int v); }};
    8. 8. Part A - Anatomy of a C++ ProgramThe classclass declaration (header file) class implementation (cpp file)class MyClass #include "myclass.h"{private: MyClass::MyClass() { int age; MyClass(0); } void anotherBirthday() { age++; MyClass::MyClass(int initialValue) { } this->setAge(initialValue); }public: MyClass(); MyClass::~MyClass() { MyClass(int initialValue); age = 0; } ~MyClass(); int getAge() { void MyClass::setAge(int v) { return age; if (age == v) return; } age = v; void setAge(int v); }};
    9. 9. Part A - Anatomy of a C++ ProgramThe classclass declaration (header file) class implementation (cpp file)class MyClass #include "myclass.h"{private: MyClass::MyClass() { int age; MyClass(0); } void anotherBirthday() { age++; MyClass::MyClass(int initialValue) { } this->setAge(initialValue); }public: MyClass(); MyClass::~MyClass() { MyClass(int initialValue); age = 0; } ~MyClass(); int getAge() { void MyClass::setAge(int v) { return age; if (age == v) return; } age = v; void setAge(int v); }};
    10. 10. Part A - Anatomy of a C++ ProgramThe classclass declaration (header file) class implementation (cpp file)class MyClass #include "myclass.h"{private: MyClass::MyClass() { int age; MyClass(0); } void anotherBirthday() { age++; MyClass::MyClass(int initialValue) { } this->setAge(initialValue); }public: MyClass(); MyClass::~MyClass() { MyClass(int initialValue); age = 0; } ~MyClass(); int getAge() { void MyClass::setAge(int v) { return age; if (age == v) return; } age = v; void setAge(int v); }};
    11. 11. Part A - Anatomy of a C++ ProgramThe classclass declaration (header file) class implementation (cpp file)class MyClass #include "myclass.h"{private: MyClass::MyClass() { int age; MyClass(0); } void anotherBirthday() { age++; MyClass::MyClass(int initialValue) { } this->setAge(initialValue); }public: MyClass(); MyClass::~MyClass() { MyClass(int initialValue); age = 0; } ~MyClass(); int getAge() { void MyClass::setAge(int v) { return age; if (age == v) return; } age = v; void setAge(int v); }};
    12. 12. Part A - Anatomy of a C++ ProgramThe classclass declaration (header file) class implementation (cpp file)class MyClass #include "myclass.h"{private: MyClass::MyClass() { int age; MyClass(0); } void anotherBirthday() { age++; MyClass::MyClass(int initialValue) { } this->setAge(initialValue); }public: MyClass(); MyClass::~MyClass() { MyClass(int initialValue); age = 0; } ~MyClass(); int getAge() { void MyClass::setAge(int v) { return age; if (age == v) return; } age = v; void setAge(int v); }};
    13. 13. Part A - Anatomy of a C++ ProgramThe classclass declaration (header file) class implementation (cpp file)class MyClass #include "myclass.h"{private: MyClass::MyClass() { int age; MyClass(0); } void anotherBirthday() { age++; MyClass::MyClass(int initialValue) { } this->setAge(initialValue); }public: MyClass(); MyClass::~MyClass() { MyClass(int initialValue); age = 0; } ~MyClass(); int getAge() { void MyClass::setAge(int v) { return age; if (age == v) return; } age = v; void setAge(int v); }};
    14. 14. Part A - Anatomy of a C++ ProgramThe classclass declaration (header file) class implementation (cpp file)class MyClass #include "myclass.h"{private: MyClass::MyClass() { int age; MyClass(0); } void anotherBirthday() { age++; MyClass::MyClass(int initialValue) { } this->setAge(initialValue); }public: MyClass(); MyClass::~MyClass() { MyClass(int initialValue); age = 0; } ~MyClass(); int getAge() { void MyClass::setAge(int v) { return age; if (age == v) return; } age = v; void setAge(int v); }};
    15. 15. Part A - Anatomy of a C++ ProgramThe classclass declaration (header file) class implementation (cpp file)class MyClass #include "myclass.h"{private: MyClass::MyClass() { int age; MyClass(0); } void anotherBirthday() { age++; MyClass::MyClass(int initialValue) { } this->setAge(initialValue); }public: MyClass(); MyClass::~MyClass() { MyClass(int initialValue); age = 0; } ~MyClass(); int getAge() { void MyClass::setAge(int v) { return age; if (age == v) return; } age = v; void setAge(int v); }};
    16. 16. Part A - Anatomy of a C++ ProgramThe classclass declaration (header file) class implementation (cpp file)class MyClass #include "myclass.h"{private: MyClass::MyClass() { int age; MyClass(0); } void anotherBirthday() { age++; MyClass::MyClass(int initialValue) { } this->setAge(initialValue); }public: MyClass(); MyClass::~MyClass() { MyClass(int initialValue); age = 0; } ~MyClass(); int getAge() { void MyClass::setAge(int v) { return age; if (age == v) return; } age = v; void setAge(int v); }};
    17. 17. Part A - Anatomy of a C++ ProgramThe classclass declaration (header file) class implementation (cpp file)class MyClass #include "myclass.h"{private: MyClass::MyClass() { int age; MyClass(0); } void anotherBirthday() { age++; MyClass::MyClass(int initialValue) { } this->setAge(initialValue); }public: MyClass(); MyClass::~MyClass() { MyClass(int initialValue); age = 0; } ~MyClass(); int getAge() { void MyClass::setAge(int v) { return age; if (age == v) return; } age = v; void setAge(int v); }};
    18. 18. Part A - Anatomy of a C++ ProgramThe classclass declaration (header file) class implementation (cpp file)class MyClass #include "myclass.h"{private: MyClass::MyClass() { int age; MyClass(0); } void anotherBirthday() { age++; MyClass::MyClass(int initialValue) { } this->setAge(initialValue); }public: MyClass(); MyClass::~MyClass() { MyClass(int initialValue); age = 0; } ~MyClass(); int getAge() { void MyClass::setAge(int v) { return age; if (age == v) return; } age = v; void setAge(int v); }};
    19. 19. Part A - Anatomy of a C++ ProgramThe classclass declaration (header file) class implementation (cpp file)class MyClass #include "myclass.h"{private: MyClass::MyClass() { int age; MyClass(0); } void anotherBirthday() { age++; MyClass::MyClass(int initialValue) { } this->setAge(initialValue); }public: MyClass(); MyClass::~MyClass() { MyClass(int initialValue); age = 0; } ~MyClass(); int getAge() { void MyClass::setAge(int v) { return age; if (age == v) return; } age = v; void setAge(int v); }};
    20. 20. Part A - Anatomy of a C++ ProgramThe classclass declaration (header file) class implementation (cpp file)class MyClass #include "myclass.h"{private: MyClass::MyClass() { int age; MyClass(0); } void anotherBirthday() { age++; MyClass::MyClass(int initialValue) { } this->setAge(initialValue); }public: MyClass(); MyClass::~MyClass() { MyClass(int initialValue); age = 0; } ~MyClass(); int getAge() { void MyClass::setAge(int v) { return age; if (age == v) return; } age = v; void setAge(int v); }};
    21. 21. Part A - Anatomy of a C++ ProgramThe classclass declaration (header file) class implementation (cpp file)class MyClass #include "myclass.h"{private: MyClass::MyClass() { int age; MyClass(0); } void anotherBirthday() { age++; MyClass::MyClass(int initialValue) { } this->setAge(initialValue); }public: MyClass(); MyClass::~MyClass() { MyClass(int initialValue); age = 0; } ~MyClass(); int getAge() { void MyClass::setAge(int v) { return age; if (age == v) return; } age = v; void setAge(int v); }};
    22. 22. Instantiating objects✤ Two options ✤ MyClass a(18); ✤ a.setAge(21);✤ Pointer type (heap only) ✤ MyClass *a; ✤ a = new MyClass(); ✤ a->setAge(21); ✤ delete a;
    23. 23. Strings✤ C++ has a standard string library ✤ #include <string> ✤ Create strings: ✤ std::string s = "Hello"; ✤ Concatenate strings using “operator overloading” ✤ s = s + " world";
    24. 24. Videos✤ See videos on the module site ✤ C++ ✤ Qt

    ×