324-lecture22 - Principles of Programming Languages...

Info iconThis preview shows pages 1–9. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Principles of Programming Languages Principles of Programming Languages Lecture 22 Lecture 22 University of Toronto Wael Aboulsaadat Wael Aboulsaadat wael@cs.toronto.edu wael@cs.toronto.edu http://portal.utoronto.ca/ 1 Components of an Imperative Language Components of an Imperative Language Data types Variables, operators & Expressions Iteration construct University of Toronto Branching construct Subprogram construct b Container construct 2 Container Construct Container Construct Syntactical variations- Prototype- Implementation Binary variations Application Library University of Toronto Component 3 Container Construct Container Construct Syntactical variations- Prototype & implementation- Implementation C/C++ separates between prototype and implementation of code class HelloWorld { public: HelloWorld(); elloWorld(); #include "hello.h" HelloWorld :: HelloWorld(){ University of Toronto 4 ~ HelloWorld(); public: //Methods: void on_button_clicked(); protected: //Attributes Button ok_button; }; // . } HelloWorld ::~ HelloWorld(){ //.. } HelloWorld :: ok_clicked(){ //. } hello.h hello.cpp Container Construct Container Construct C/C++ separates between prototype and implementation of code Decreases writability: have to maintain 2 files per class/set of functions. class HelloWorld { public: HelloWorld(); elloWorld(); #include "hello.h" HelloWorld :: HelloWorld(){ #include "hello.h" University of Toronto 5 ~ HelloWorld(); public: //Methods: void printMessage(); protected: //Attributes Button ok_button; }; // . } HelloWorld ::~ HelloWorld(){ //.. } HelloWorld :: printMessage(){ //. } hello.h hello.cpp App.cpp int main (){ HelloWorld hello; hello.printMessage (); } Container Construct Container Construct Languages which separates prototype from implementation often force programmer to handle circular references which will break compilation! App.cpp #include x.h #include y.h" University of Toronto 6 x.cpp y.cpp x.h y.h #include y.h" #include x.h" #include x.h" #include y.h" Container Construct Container Construct Languages which separates prototype from implementation often force programmer to handle circular references which will break compilation! ifdef ensures that a file is included by the compiler #ifndef HELLO #define HELLO class HelloWorld { public: elloWorld(); University of Toronto only once 7 hello.h HelloWorld(); ~ HelloWorld(); public: //Methods: void printMessage(); protected: //Attributes Button ok_button; }; #endif Container Construct Container Construct Binary variations: Library A library is a set of functions packaged in one file....
View Full Document

Page1 / 26

324-lecture22 - Principles of Programming Languages...

This preview shows document pages 1 - 9. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online