Presentation is loading. Please wait.

Presentation is loading. Please wait.

ITEC 320 Lecture 24 OO in Ada (2). Review Questions? Inheritance in Ada.

Similar presentations


Presentation on theme: "ITEC 320 Lecture 24 OO in Ada (2). Review Questions? Inheritance in Ada."— Presentation transcript:

1 ITEC 320 Lecture 24 OO in Ada (2)

2 Review Questions? Inheritance in Ada

3 OO in Ada(2) Abstract types What are they? Why are they used?

4 OO in Ada(2) Abstract types

5 OO in Ada(2) Example What do you think this means? package P is type T is abstract tagged record … end record; Procedure Op(X: T) is abstract; end p;

6 OO in Ada(2) Interfaces Code package Q is type Int is interface; procedure Op(X: Int) is abstract; procedure N(X: Int) is null; procedure Action(X: Int’Class); end Q; Similar, except not allowed to contain information like a record.

7 OO in Ada(2) Why? What do you think the purpose of abstract / interface capabilities are? What scenarios do they allow? What do they prevent?

8 OO in Ada(2) Shortcut Java syntax –varName.methodName(params); Ada syntax –procedureName(records); record X is … end record procedure Op(var: X, other params here)… Can be called with X.Op(other params); --Ada and Java sitting in a tree Note: has to be tagged and class wide

9 OO in Ada(2) Private variables Keep the user away from your data! package Geometry is type Object is abstract tagged private; private type Object is tagged record x_coord : Float; y_coord : Float; end record; end Geometry; Requires a child package to inherit / use the Object class

10 OO in Ada(2) Multiple inheritance C++ method –Diamond problem Java method Ada method –Can inherit from one tagged –All others have to be interfaces Allows for procedures / functions type NT is new T and Int1 and Int2 with …

11 OO in Ada(2) Ada.fin Finished with Ada –What is different? –What is better? –What is worse? Now moving on to C++

12 OO in Ada(2) C++ intro History then Coding

13 OO in Ada(2) C++ History of C++… “C++ was designed to provide Simula’s facilities for program organization together with C’s efficiency and flexibility for systems programming. “ Write coding in assembly, C, C++….

14 OO in Ada(2) OO Simula 67 –1965 (Vietnam, civil rights, Thunderbirds debuted) –Based off of algol… –Introduced basics of OO programming that we use today –Classes, inheritance, class variables, instance variables, class methods (virtual)

15 OO in Ada(2) C Multiple people using a computer at the same time… Broken project called Multics…. Need was still there, it became UNIX Needed a language for the new OS… –CPL,BCPL,B, then C!

16 OO in Ada(2) Pictures Simula 67 Beautiful yet impractical C Ridiculously fast, yet difficult to work with C++ = +

17 OO in Ada(2) Java Some parts are C-like Memory management? Designed not to fail YouComputer

18 OO in Ada(2) C++ Complete control –Assembly to OO Memory management Speed Used widely Did you check if all seven pointers were non-null or only six? Do you feel lucky, well do ya? “If programming in Pascal is like being put in a straightjacket, then programming in C is like playing with knives, and programming in C++ is like juggling chainsaws.” – Anonymous

19 OO in Ada(2) Hello World #include using namespace std; int main(int argc, char** argv) { string hello = "Hello World"; cout << hello << endl; return 0; } Command Prompt: vi hello.cpp g++ -o Hello hello.cpp./Hello System libraries Standard namespace (functions?) Function definition, entry point for every C/C++ program (command line args) String class and initialization Print to console Return code of program to OS Returns 0, can be used with scripts

20 OO in Ada(2) Producing programs File.java File.class javac java JVM conversion Actual machine code file.cpp file g++ –o file file.c Machine code that executes

21 OO in Ada(2) Tools g++ - Free C++ compiler VI / Emacs / Crimson editor (or others) putty and rucs / your own linux machine C++ should be portable between windows and linux…it usually isn’t Develop on platform you use to demonstrate…

22 OO in Ada(2) Memory JavaC++

23 OO in Ada(2) Summary Abstract types


Download ppt "ITEC 320 Lecture 24 OO in Ada (2). Review Questions? Inheritance in Ada."

Similar presentations


Ads by Google