Îmbunătăţiri aduse în limbajul C++ facilităţilor standard ale limbajului C (cele care nu ţin de conceptele programării orientate obiect).
|
|
- Jacob Black
- 6 years ago
- Views:
Transcription
1 Îmbunătăţiri aduse în limbajul C++ facilităţilor standard ale limbajului C (cele care nu ţin de conceptele programării orientate obiect). Supraîncărcarea numelui de funcţii (overloading) In C nu este permisa existenta a doua functii cu acelasi nume. In C++ acest lucru este posibil cu urmatoarea precizare: functiile nu pot sa difere doar prin valoarea returnata. Asadar este necesar ca lista de parametrii sa fie diferita. int Add(int x, int y) return x + y ; char* Add(char* x, char* y) char* tmp = new char [strlen(x)+strlen(y)+1] ; strcpy(tmp, x) ; strcpy(tmp+strlen(x), y) ; return tmp ; Valori implicite pentru argumentele unei funcţii Parametrii unei functi pot lua valori implicite. Daca la apelul unei functii lipseste un parametru caruia i-a fost precizata o valoare implicita, compilatorul va atribui aceasta valoare in momentul apelului. int f(int x, char* name = NULL) if(name) cout << "Nume = " << name << "\n" ; return x ; Obs: Pot aparea unele erori. De exemplu, sa presupunem ca mai avem si urmatoarea functie: int f(int x) return x ; void main(void) int x = f(1, "Laborator"); // Linia urmatoarea va genera o eroare la compilare deoarece // compilatorul nu poate decide care din cele doua functii f // sa utilizeze caci ambele au primii n (aici n=1) de acelasi tip // int y = f(1); Comentarii folosind // Pe langa vechiul stil de comentarii (/* si */), care ramine valabil, s-a introdus un nou mod de a specifica comentarii: single-line comment. Caracterele unei linii ce urmeaza perechii de caractere // (doua slash-uri) sunt considerate comentarii.
2 int age; // Virsta persoanei int age; /* Virsta persoanei */ Funcţii inline Cuvintul cheie inline pus in fata unei functii indica compilatorului sa expandeze acea functie in momentul compilarii, astfel incit codul obiect genrat nu va contine un apel de functie, ci va contine codul obiect corespunzator acelei functii. Obs: inline este doar o indicatie, a carei implementare difera de la compilator la compilator (de ex: Borland C va expanda functiile inline ce contin instructiuni repetitive (for, while), in timp ce VC face acest lucru. De asemenea, exista cazuri in care compilatorul nu poate expanda functia inline. In aceste cazuri se va apela functia in mod normal. Avantajul functiilor inline este viteza sporita de executie. Se recomanda folosirea lor in cazul in care numarul de parametrii este redus, iar corpul functiei nu contine multe instructiuni. Inlocuiesc cu succes macrourile construite cu #define si evita neajunsurile acestor cauzate de expandarea codului sursa: - nu pot returna valori - parametrii trebuie sa fie precizati intre paranteze, pentru o evaluarea conforma cu precedenta operatorilor. Deasemenea permit o verificare de tip. #define Max(a,b) ((a)<(b))? (b) : (a) inline int Max(int a, int b) return (a<b)? b : a ; Operatorii new şi delete pentru alocarea/eliberarea memoriei Spre deosebire de limbajul C (in care managementul memoriei era implementat in biblioteci auxiliare si era pus la dispozitia programatorilor prin intermediul unor functii), in C++ au fost introdusi doi noi operatori pentru managementul memoriei: - new pentru alocarea memoriei - delete pentru dealocarea memoriei Acesti operatori, pe langa alocara zonei de memoriei necesare, efectueaza in plus opeartiile necesare initializarii zonei respective, care sunt extrem de importante in cazul obiectelor. int main(int argc, char* argv[]) char * str = new char [100]; delete [] str; Final remarks: o obligativitatea declarării funcţiilor înainte de apel o NU se face conversie implicita a tipului pointerilor "void*" in alte tipuri de pointeri
3 EXERCISE Să se scrie funcţii pentru adunarea a două numere întregi, pentru concatenarea a două şiruri de caractere si pentru inversarea a două numere întregi. #include <iostream.h> #include <string.h> inline int add(int x, int y ) return x + y ; char* add(char* x, char* y) char* tmp = new char [strlen(x)+strlen(y)+1] ; strcpy(tmp, x) ; strcpy(tmp+strlen(x), y) ; return tmp ; void swap(int& x, int& y) int t = x ; x = y ; y = t ; void logo (bool bon = true) if(bon) cout << "Hello, world of C++\n" ; else cout << "See you next lab ;-)\n" ; int main(void) logo() ; int x, y ; char szprenume[] = "West University", sznume[] = " Timisoara" ; cin >> x >> y ; cout << "x= " << x << " y= " << y << " x+y= " << add(x,y) << '\n'; swap(x, y); cout << "x = " << x << " y = " << y << '\n' ; char* result = add(szprenume, sznume) ; cout << " String add result = " << result << '\n' ; delete [] result ; logo(false) ; return (1) ;
4 APPENDIX A. Keywords Cuvintele cheie (keywords) ale limbajului C++ sunt: asm auto bad_cast bad_typeid bool break case catch char class const const_cast continue default delete do double dynamic_cast else enum except explicit extern false finally float for friend goto if inline int long mutable namespace new operator private protected public register reinterpret_cast return short signed sizeof static static_cast struct switch template this throw true try type_info typedef typeid typename union unsigned using virtual void volatile while xalloc Obs: Cuvintele cheie nu pot fi folosite ca nume de identificatori (variabile, functii, clase etc.).
5 APPENDIX B. Operators Operatorii limbajului C++ (de la cea mai inalta la cea mai scazuta prioritate) sunt: Operator Name / Meaning Associativity :: Scope resolution None :: Global None [ ] Array subscript Left to right ( ) Function call Left to right ( ) Conversion None. Member selection (object) Left to right -> Member selection (pointer) Left to right ++ Postfix increment None -- Postfix decrement None new Allocate object None delete Deallocate object None delete[ ] Deallocate object None ++ Prefix increment None -- Prefix decrement None * Dereference None & Address-of None + Unary plus None - Arithmetic negation (unary) None! Logical NOT None ~ Bitwise complement None sizeof Size of object None sizeof ( ) Size of type None typeid( ) type name None (type) Type cast (conversion) Right to left const_cast Type cast (conversion) None dynamic_cast Type cast (conversion) None reinterpret_cast Type cast (conversion) None static_cast Type cast (conversion) None.* Apply pointer to class member (objects) Left to right ->* Dereference pointer to class member Left to right * Multiplication Left to right / Division Left to right % Remainder (modulus) Left to right + Addition Left to right - Subtraction Left to right << Left shift Left to right >> Right shift Left to right < Less than Left to right > Greater than Left to right <= Less than or equal to Left to right >= Greater than or equal to Left to right == Equality Left to right!= Inequality Left to right & Bitwise AND Left to right ^ Bitwise exclusive OR Left to right Bitwise OR Left to right && Logical AND Left to right
6 Logical OR Left to right e1?e2:e3 Conditional Right to left = Assignment Right to left *= Multiplication assignment Right to left /= Division assignment Right to left %= Modulus assignment Right to left += Addition assignment Right to left -= Subtraction assignment Right to left <<= Left-shift assignment Right to left >>= Right-shift assignment Right to left &= Bitwise AND assignment Right to left = Bitwise inclusive OR assignment Right to left ^= Bitwise exclusive OR assignment Right to left, Comma Left to right Obs: a) Operatorii pot fi redefiniti la nivel global sau la nivel de clasa (overloading). b) Urmatorii operatori NU pot fi redefiniti:.,.*, ::,? :, #, ##. c) Au fost introdusi operatori noi: new, delete,.*, ->,*.
7 Îmbunătăţiri aduse în limbajul C++ facilităţilor standard ale limbajului C (cele care nu ţin de conceptele programării orientate obiect). Supraîncărcarea numelui de funcţii (overloading) In C nu este permisa existenta a doua functii cu acelasi nume. In C++ acest lucru este posibil cu urmatoarea precizare: functiile nu pot sa difere doar prin valoarea returnata. Asadar este necesar ca lista de parametrii sa fie diferita. int Add(int x, int y) return x + y ; char* Add(char* x, char* y) char* tmp = new char [strlen(x)+strlen(y)+1] ; strcpy(tmp, x) ; strcpy(tmp+strlen(x), y) ; return tmp ; Valori implicite pentru argumentele unei funcţii Parametrii unei functi pot lua valori implicite. Daca la apelul unei functii lipseste un parametru caruia i-a fost precizata o valoare implicita, compilatorul va atribui aceasta valoare in momentul apelului. int f(int x, char* name = NULL) if(name) cout << "Nume = " << name << "\n" ; return x ; Obs: Pot aparea unele erori. De exemplu, sa presupunem ca mai avem si urmatoarea functie: int f(int x) return x ; void main(void) int x = f(1, "Laborator"); // Linia urmatoarea va genera o eroare la compilare deoarece // compilatorul nu poate decide care din cele doua functii f // sa utilizeze caci ambele au primele n (aici n=1) argumente de acelasi tip // int y = f(1); Comentarii folosind // Pe langa vechiul stil de comentarii (/* si */), care ramine valabil, s-a introdus un nou mod de a specifica comentarii: single-line comment. Caracterele unei linii ce urmeaza perechii de caractere // (doua slash-uri) sunt considerate comentarii.
8 int age; // Virsta persoanei int age; /* Virsta persoanei */ Funcţii inline Cuvintul cheie inline pus in fata unei functii indica compilatorului sa expandeze acea functie in momentul compilarii, astfel incit codul obiect genrat nu va contine un apel de functie, ci va contine codul obiect corespunzator acelei functii. Obs: inline este doar o indicatie, a carei implementare difera de la compilator la compilator (de ex: Borland C va expanda functiile inline ce contin instructiuni repetitive (for, while), in timp ce VC face acest lucru. De asemenea, exista cazuri in care compilatorul nu poate expanda functia inline. In aceste cazuri se va apela functia in mod normal. Avantajul functiilor inline este viteza sporita de executie. Se recomanda folosirea lor in cazul in care numarul de parametrii este redus, iar corpul functiei nu contine multe instructiuni. Inlocuiesc cu succes macrourile construite cu #define si evita neajunsurile acestor cauzate de expandarea codului sursa: - nu pot returna valori - parametrii trebuie sa fie precizati intre paranteze, pentru o evaluarea conforma cu precedenta operatorilor. Deasemenea permit o verificare de tip. #define Max(a,b) ((a)<(b))? (b) : (a)) inline int Max(int a, int b) return (a<b)? b : a ; Operatorii new şi delete pentru alocarea/eliberarea memoriei Spre deosebire de limbajul C (in care managementul memoriei era implementat in biblioteci auxiliare si era pus la dispozitia programatorilor prin intermediul unor functii), in C++ au fost introdusi doi noi operatori pentru managementul memoriei: - new pentru alocarea memoriei - delete pentru dealocarea memoriei Acesti operatori, pe langa alocara zonei de memoriei necesare, efectueaza in plus opeartiile necesare initializarii zonei respective, care sunt extrem de importante in cazul obiectelor. int main(int argc, char* argv[]) char * str = new char [100]; delete [] str; Final remarks: o obligativitatea declarării funcţiilor înainte de apel o NU se face conversie implicita a tipului pointerilor "void*" in alte tipuri de pointeri
9 EXERCISE Să se scrie funcţii pentru adunarea a două numere întregi, pentru concatenarea a două şiruri de caractere si pentru inversarea a două numere întregi. #include <iostream.h> #include <string.h> inline int add(int x, int y ) return x + y ; char* add(char* x, char* y) char* tmp = new char [strlen(x)+strlen(y)+1] ; strcpy(tmp, x) ; strcpy(tmp+strlen(x), y) ; return tmp ; void swap(int& x, int& y) int t = x ; x = y ; y = t ; void logo (bool bon = true) if(bon) cout << "Hello, world of C++\n" ; else cout << "See you next lab ;-)\n" ; int main(void) logo() ; int x, y ; char szprenume[] = "West University", sznume[] = " Timisoara" ; cin >> x >> y ; cout << "x= " << x << " y= " << y << " x+y= " << add(x,y) << '\n'; swap(x, y); cout << "x = " << x << " y = " << y << '\n' ; char* result = add(szprenume, sznume) ; cout << " String add result = " << result << '\n' ; delete [] result ; logo(false) ; return (1) ;
10 APPENDIX A. Keywords Cuvintele cheie (keywords) ale limbajului C++ sunt: asm auto bad_cast bad_typeid bool break case catch char class const const_cast continue default delete do double dynamic_cast else enum except explicit extern false finally float for friend goto if inline int long mutable namespace new operator private protected public register reinterpret_cast return short signed sizeof static static_cast struct switch template this throw true try type_info typedef typeid typename union unsigned using virtual void volatile while xalloc Obs: Cuvintele cheie nu pot fi folosite ca nume de identificatori (variabile, functii, clase etc.).
11 APPENDIX B. Operators Operatorii limbajului C++ (de la cea mai inalta la cea mai scazuta prioritate) sunt: Operator Name / Meaning Associativity :: Scope resolution None :: Global None [ ] Array subscript Left to right ( ) Function call Left to right ( ) Conversion None. Member selection (object) Left to right -> Member selection (pointer) Left to right ++ Postfix increment None -- Postfix decrement None new Allocate object None delete Deallocate object None delete[ ] Deallocate object None ++ Prefix increment None -- Prefix decrement None * Dereference None & Address-of None + Unary plus None - Arithmetic negation (unary) None! Logical NOT None ~ Bitwise complement None sizeof Size of object None sizeof ( ) Size of type None typeid( ) type name None (type) Type cast (conversion) Right to left const_cast Type cast (conversion) None dynamic_cast Type cast (conversion) None reinterpret_cast Type cast (conversion) None static_cast Type cast (conversion) None.* Apply pointer to class member (objects) Left to right ->* Dereference pointer to class member Left to right * Multiplication Left to right / Division Left to right % Remainder (modulus) Left to right + Addition Left to right - Subtraction Left to right << Left shift Left to right >> Right shift Left to right < Less than Left to right > Greater than Left to right <= Less than or equal to Left to right >= Greater than or equal to Left to right == Equality Left to right!= Inequality Left to right & Bitwise AND Left to right ^ Bitwise exclusive OR Left to right Bitwise OR Left to right && Logical AND Left to right
12 Logical OR Left to right e1?e2:e3 Conditional Right to left = Assignment Right to left *= Multiplication assignment Right to left /= Division assignment Right to left %= Modulus assignment Right to left += Addition assignment Right to left -= Subtraction assignment Right to left <<= Left-shift assignment Right to left >>= Right-shift assignment Right to left &= Bitwise AND assignment Right to left = Bitwise inclusive OR assignment Right to left ^= Bitwise exclusive OR assignment Right to left, Comma Left to right Obs: a) Operatorii pot fi redefiniti la nivel global sau la nivel de clasa (overloading). b) Urmatorii operatori NU pot fi redefiniti:.,.*, ::,? :, #, ##. c) Au fost introdusi operatori noi: new, delete,.*, ->,*.
Incompatibilities / Differences between C and C++
Incompatibilities / Differences between C and C++ 1. Objectives 1. The resolution operator 2. The operators new and delete 3. Inline functions 4. Functions returning a reference data type 5. Call by reference
More informationTokens, Expressions and Control Structures
3 Tokens, Expressions and Control Structures Tokens Keywords Identifiers Data types User-defined types Derived types Symbolic constants Declaration of variables Initialization Reference variables Type
More informationIntroduction to Programming
Introduction to Programming session 6 Instructor: Reza Entezari-Maleki Email: entezari@ce.sharif.edu 1 Spring 2011 These slides are created using Deitel s slides Sharif University of Technology Outlines
More informationFişiere in C++ Un fişier este o colecţie de date indicat printr-un nume şi o extensie. Numele este desparţit de extensie prin punct.
Fişiere in C++ Un fişier este o colecţie de date indicat printr-un nume şi o extensie. Numele este desparţit de extensie prin punct. Avantajul lucrului cu fisiere este evident, datele rezultate în urma
More informationAPPENDIX A : KEYWORDS... 2 APPENDIX B : OPERATORS... 3 APPENDIX C : OPERATOR PRECEDENCE... 4 APPENDIX D : ESCAPE SEQUENCES... 5
APPENDIX A : KEYWORDS... 2 APPENDIX B : OPERATORS... 3 APPENDIX C : OPERATOR PRECEDENCE... 4 APPENDIX D : ESCAPE SEQUENCES... 5 APPENDIX E : ASCII CHARACTER SET... 6 APPENDIX F : USING THE GCC COMPILER
More informationVariables. Data Types.
Variables. Data Types. The usefulness of the "Hello World" programs shown in the previous section is quite questionable. We had to write several lines of code, compile them, and then execute the resulting
More informationCharacter Set. The character set of C represents alphabet, digit or any symbol used to represent information. Digits 0, 1, 2, 3, 9
Character Set The character set of C represents alphabet, digit or any symbol used to represent information. Types Uppercase Alphabets Lowercase Alphabets Character Set A, B, C, Y, Z a, b, c, y, z Digits
More informationAlocarea memoriei în C sub Linux
Costel Aldea Alocarea memoriei în C sub Linux Sunt trei funcţii C standard care se pot folosi pentru a aloca memorie: malloc(), calloc(), si realloc(). Prototipurile lor, după cum sunt definite în stdlib.h:
More informationAppendix. Grammar. A.1 Introduction. A.2 Keywords. There is no worse danger for a teacher than to teach words instead of things.
A Appendix Grammar There is no worse danger for a teacher than to teach words instead of things. Marc Block Introduction keywords lexical conventions programs expressions statements declarations declarators
More informationUniversity of Technology. Laser & Optoelectronics Engineering Department. C++ Lab.
University of Technology Laser & Optoelectronics Engineering Department C++ Lab. Second week Variables Data Types. The usefulness of the "Hello World" programs shown in the previous section is quite questionable.
More informationChapter 15 - C++ As A "Better C"
Chapter 15 - C++ As A "Better C" Outline 15.1 Introduction 15.2 C++ 15.3 A Simple Program: Adding Two Integers 15.4 C++ Standard Library 15.5 Header Files 15.6 Inline Functions 15.7 References and Reference
More informationCprE 288 Introduction to Embedded Systems Exam 1 Review. 1
CprE 288 Introduction to Embedded Systems Exam 1 Review http://class.ece.iastate.edu/cpre288 1 Overview of Today s Lecture Announcements Exam 1 Review http://class.ece.iastate.edu/cpre288 2 Announcements
More informationIntroduction to C++ Systems Programming
Introduction to C++ Systems Programming Introduction to C++ Syntax differences between C and C++ A Simple C++ Example C++ Input/Output C++ Libraries C++ Header Files Another Simple C++ Example Inline Functions
More informationAssignment Operations
ECE 114-4 Control Statements-2 Dr. Z. Aliyazicioglu Cal Poly Pomona Electrical & Computer Engineering Cal Poly Pomona Electrical & Computer Engineering 1 Assignment Operations C++ provides several assignment
More informationLaborator 8 Java Crearea claselor de obiecte. Variabilele (campurile) clasei de obiecte
Laborator 8 Java Crearea claselor de obiecte. Variabilele (campurile) clasei de obiecte Probleme rezolvate: Scrieti, compilati si rulati toate exemplele din acest laborator: 1. Programul urmator (LotoConstante.java)
More informationLEXICAL 2 CONVENTIONS
LEXIAL 2 ONVENTIONS hapter SYS-ED/ OMPUTER EDUATION TEHNIQUES, IN. ++ Programming Lexical onventions Objectives You will learn: Operators. Punctuators. omments. Identifiers. Literals. SYS-ED \OMPUTER EDUATION
More informationLaborator 5 Instrucțiunile repetitive
Laborator 5 Instrucțiunile repetitive Instrucțiunea for Instrucțiunea for permite repetarea unei secvențe de instrucțiuni atâta timp cât o condiție este îndeplinita. În plus, oferă posibilitatea execuției
More informationBasic Types, Variables, Literals, Constants
Basic Types, Variables, Literals, Constants What is in a Word? A byte is the basic addressable unit of memory in RAM Typically it is 8 bits (octet) But some machines had 7, or 9, or... A word is the basic
More informationProgramming. C++ Basics
Programming C++ Basics Introduction to C++ C is a programming language developed in the 1970s with the UNIX operating system C programs are efficient and portable across different hardware platforms C++
More informationME240 Computation for Mechanical Engineering. Lecture 4. C++ Data Types
ME240 Computation for Mechanical Engineering Lecture 4 C++ Data Types Introduction In this lecture we will learn some fundamental elements of C++: Introduction Data Types Identifiers Variables Constants
More informationNon-numeric types, boolean types, arithmetic. operators. Comp Sci 1570 Introduction to C++ Non-numeric types. const. Reserved words.
, ean, arithmetic s s on acters Comp Sci 1570 Introduction to C++ Outline s s on acters 1 2 3 4 s s on acters Outline s s on acters 1 2 3 4 s s on acters ASCII s s on acters ASCII s s on acters Type: acter
More informationRecap. ANSI C Reserved Words C++ Multimedia Programming Lecture 2. Erwin M. Bakker Joachim Rijsdam
Multimedia Programming 2004 Lecture 2 Erwin M. Bakker Joachim Rijsdam Recap Learning C++ by example No groups: everybody should experience developing and programming in C++! Assignments will determine
More informationUNIT- 3 Introduction to C++
UNIT- 3 Introduction to C++ C++ Character Sets: Letters A-Z, a-z Digits 0-9 Special Symbols Space + - * / ^ \ ( ) [ ] =!= . $, ; : %! &? _ # = @ White Spaces Blank spaces, horizontal tab, carriage
More informationTehnici avansate de programare
Tehnici avansate de programare Curs - Cristian Frăsinaru acf@infoiasi.ro Facultatea de Informatică Universitatea Al. I. Cuza Iaşi Adnotarea elementelor Tehnici avansate de programare p.1/1 Cuprins Ce sunt
More informationIS 0020 Program Design and Software Tools
1 IS 0020 Program Design and Software Tools Introduction to C++ Programming Spring 2005 Lecture 1 Jan 6, 2005 Course Information 2 Lecture: James B D Joshi Tuesdays/Thursdays: 1:00-2:15 PM Office Hours:
More informationReview of the C Programming Language for Principles of Operating Systems
Review of the C Programming Language for Principles of Operating Systems Prof. James L. Frankel Harvard University Version of 7:26 PM 4-Sep-2018 Copyright 2018, 2016, 2015 James L. Frankel. All rights
More informationBasics of C++ // my first program in C++ Hello World! #include <iostream> using namespace std; int main () { cout << "Hello World!
Basics of C++ // my first program in C++ Hello World! cout
More informationOperatori. Comentarii. Curs 1
Operatori atribuirea: = operatori matematici: +, -, *, /, % Este permisa notatia prescurtata de forma lval op= rval (ex: n += 2) Exista operatorii pentru autoincrementare si autodecrementare (post si pre)
More informationstd::cout << "Size of long = " << sizeof(long) << " bytes\n\n"; std::cout << "Size of char = " << sizeof(char) << " bytes\n";
C++ Program Structure A C++ program must adhere to certain structural constraints. A C++ program consists of a sequence of statements. Every program has exactly one function called main. Programs are built
More informationEEE145 Computer Programming
EEE145 Computer Programming Content of Topic 2 Extracted from cpp.gantep.edu.tr Topic 2 Dr. Ahmet BİNGÜL Department of Engineering Physics University of Gaziantep Modifications by Dr. Andrew BEDDALL Department
More informationC/Java Syntax. January 13, Slides by Mark Hancock (adapted from notes by Craig Schock)
C/Java Syntax 1 Lecture 02 Summary Keywords Variable Declarations Data Types Operators Statements if, switch, while, do-while, for Functions 2 By the end of this lecture, you will be able to identify the
More informationC/Java Syntax. Lecture 02 Summary. Keywords Variable Declarations Data Types Operators Statements. Functions. if, switch, while, do-while, for
C/Java Syntax 1 Lecture 02 Summary Keywords Variable Declarations Data Types Operators Statements if, switch, while, do-while, for Functions 2 1 By the end of this lecture, you will be able to identify
More informationPreface to the Second Edition Preface to the First Edition Brief Contents Introduction to C++ p. 1 A Review of Structures p.
Preface to the Second Edition p. iii Preface to the First Edition p. vi Brief Contents p. ix Introduction to C++ p. 1 A Review of Structures p. 1 The Need for Structures p. 1 Creating a New Data Type Using
More informationBirotică Profesională. Cursul 12
Birotică Profesională Cursul 12 Sumar Visual Basic for Applications (VBA) Tipuri de date Structuri de control Funcţii si proceduri Obiecte si colecţii VBA Mediu de programare destinat in special realizării
More information6.096 Introduction to C++ January (IAP) 2009
MIT OpenCourseWare http://ocw.mit.edu 6.096 Introduction to C++ January (IAP) 2009 For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms. Welcome to 6.096 Lecture
More informationLecture 02 Summary. C/Java Syntax 1/14/2009. Keywords Variable Declarations Data Types Operators Statements. Functions
Lecture 02 Summary C/Java Syntax Keywords Variable Declarations Data Types Operators Statements if, switch, while, do-while, for Functions 1 2 By the end of this lecture, you will be able to identify the
More informationCapitolul 8 Funcţii în limbajul C
Obiectiv: stabilirea avantajelor pe care le aduce în programarea structurată folosirea funcţiilor. Activităţi: - Prezentarea funcţiilor definite de utilizator - Descrierea parametrilor formali şi a parametrilor
More informationIntroduction to C++ Professor Hugh C. Lauer CS-2303, System Programming Concepts
Introduction to C++ Professor Hugh C. Lauer CS-2303, System Programming Concepts (Slides include materials from The C Programming Language, 2 nd edition, by Kernighan and Ritchie, Absolute C++, by Walter
More informationDEPARTMENT OF MATHS, MJ COLLEGE
T. Y. B.Sc. Mathematics MTH- 356 (A) : Programming in C Unit 1 : Basic Concepts Syllabus : Introduction, Character set, C token, Keywords, Constants, Variables, Data types, Symbolic constants, Over flow,
More informationRezolvare fişă de laborator Java Iniţiere în limbajul Java
Rezolvare fişă de laborator Java Iniţiere în limbajul Java Ex 1: Scrie următorul program Java folosind JCreator apoi încercă să-l înţelegi. public class primulprg System.out.println("Acesta este primul
More informationReview of the C Programming Language
Review of the C Programming Language Prof. James L. Frankel Harvard University Version of 11:55 AM 22-Apr-2018 Copyright 2018, 2016, 2015 James L. Frankel. All rights reserved. Reference Manual for the
More informationInformatics Ingeniería en Electrónica y Automática Industrial
Informatics Ingeniería en Electrónica y Automática Industrial Operators and expressions in C Operators and expressions in C Numerical expressions and operators Arithmetical operators Relational and logical
More informationA flow chart is a graphical or symbolic representation of a process.
Q1. Define Algorithm with example? Answer:- A sequential solution of any program that written in human language, called algorithm. Algorithm is first step of the solution process, after the analysis of
More informationCompiler Construction. Lecture 10
Compiler Construction Lecture 10 Using Generated Scanner void main() { FlexLexer lex; int tc = lex.yylex(); while(tc!= 0) cout
More informationGO - OPERATORS. This tutorial will explain the arithmetic, relational, logical, bitwise, assignment and other operators one by one.
http://www.tutorialspoint.com/go/go_operators.htm GO - OPERATORS Copyright tutorialspoint.com An operator is a symbol that tells the compiler to perform specific mathematical or logical manipulations.
More informationCOMP322 - Introduction to C++ Lecture 02 - Basics of C++
COMP322 - Introduction to C++ Lecture 02 - Basics of C++ School of Computer Science 16 January 2012 C++ basics - Arithmetic operators Where possible, C++ will automatically convert among the basic types.
More informationUtilizarea formularelor in HTML
Utilizarea formularelor in HTML Formulare Un formular este constituit din elemente speciale, denumite elemente de control (controls), cum ar fi butoane radio, butoane de validare, câmpuri text, butoane
More informationC OVERVIEW. C Overview. Goals speed portability allow access to features of the architecture speed
C Overview C OVERVIEW Goals speed portability allow access to features of the architecture speed C fast executables allows high-level structure without losing access to machine features many popular languages
More informationOBJECT ORIENTED PROGRAMMING
OBJECT ORIENTED PROGRAMMING LAB 1 REVIEW THE STRUCTURE OF A C/C++ PROGRAM. TESTING PROGRAMMING SKILLS. COMPARISON BETWEEN PROCEDURAL PROGRAMMING AND OBJECT ORIENTED PROGRAMMING Course basics The Object
More informationOBJECT ORIENTED PROGRAMMING USING C++
OBJECT ORIENTED PROGRAMMING USING C++ Overview of C++ Overloading Overloading occurs when the same operator or function name is used with different signatures Both operators and functions can be overloaded
More informationC OVERVIEW BASIC C PROGRAM STRUCTURE. C Overview. Basic C Program Structure
C Overview Basic C Program Structure C OVERVIEW BASIC C PROGRAM STRUCTURE Goals The function main( )is found in every C program and is where every C program begins speed execution portability C uses braces
More informationProiectarea Rețelelor 32. Controlul modelelor de trafic in retea prin alterarea atributelor BGP
Platformă de e-learning și curriculă e-content pentru învățământul superior tehnic Proiectarea Rețelelor 32. Controlul modelelor de trafic in retea prin alterarea atributelor BGP De ce ebgp? De ce ibgp?
More information.Net Technologies. Components of.net Framework
.Net Technologies Components of.net Framework There are many articles are available in the web on this topic; I just want to add one more article over the web by explaining Components of.net Framework.
More informationProgramming with C++ Language
Programming with C++ Language Fourth stage Prepared by: Eng. Samir Jasim Ahmed Email: engsamirjasim@yahoo.com Prepared By: Eng. Samir Jasim Page 1 Introduction: Programming languages: A programming language
More informationLecture 02 C FUNDAMENTALS
Lecture 02 C FUNDAMENTALS 1 Keywords C Fundamentals auto double int struct break else long switch case enum register typedef char extern return union const float short unsigned continue for signed void
More informationLucrarea nr. 2. Funcţii şi structuri în C++
Lucrarea nr. 2 Funcţii şi structuri în C++ Pe măsură ce programele cresc in complexitate şi dimensiune, ele trebuiesc împărţite în fragmente mai mici şi mai uşor de gestionat numite funcţii. Funcţiile
More informationSTUDY NOTES UNIT 1 - INTRODUCTION TO OBJECT ORIENTED PROGRAMMING
OBJECT ORIENTED PROGRAMMING STUDY NOTES UNIT 1 - INTRODUCTION TO OBJECT ORIENTED PROGRAMMING 1. Object Oriented Programming Paradigms 2. Comparison of Programming Paradigms 3. Basic Object Oriented Programming
More information1. Să se determine de câte ori apare cifra c în scrierea în baza p a numărului n.
Observatii: Codul de mai jos a fost realizat si testat pe pagina online: https://www.tutorialspoint.com/compile_pascal_online.php 1. Să se determine de câte ori apare cifra c în scrierea în baza p a numărului
More informationUnit-II Programming and Problem Solving (BE1/4 CSE-2)
Unit-II Programming and Problem Solving (BE1/4 CSE-2) Problem Solving: Algorithm: It is a part of the plan for the computer program. An algorithm is an effective procedure for solving a problem in a finite
More informationMechatronics and Microcontrollers. Szilárd Aradi PhD Refresh of C
Mechatronics and Microcontrollers Szilárd Aradi PhD Refresh of C About the C programming language The C programming language is developed by Dennis M Ritchie in the beginning of the 70s One of the most
More informationChapter 2 - Control Structures
Chapter 2 - Control Structures 1 Outline 2.1 Introduction 2.2 Algorithms 2.3 Pseudocode 2.4 Control Structures 2.5 if Selection Structure 2.6 if/else Selection Structure 2.7 while Repetition Structure
More informationChapter 2. Procedural Programming
Chapter 2 Procedural Programming 2: Preview Basic concepts that are similar in both Java and C++, including: standard data types control structures I/O functions Dynamic memory management, and some basic
More informationPrinceton University COS 333: Advanced Programming Techniques A Subset of C90
Princeton University COS 333: Advanced Programming Techniques A Subset of C90 Program Structure /* Print "hello, world" to stdout. Return 0. */ { printf("hello, world\n"); -----------------------------------------------------------------------------------
More informationDivyakant Meva. Table 1. The C++ keywords
Chapter 1 Identifiers In C/C++, the names of variables, functions, labels, and various other user-defined objects are called identifiers. These identifiers can vary from one to several characters. The
More informationExpressions and Precedence. Last updated 12/10/18
Expressions and Precedence Last updated 12/10/18 Expression: Sequence of Operators and Operands that reduce to a single value Simple and Complex Expressions Subject to Precedence and Associativity Six
More informationCS3157: Advanced Programming. Outline
CS3157: Advanced Programming Lecture #12 Apr 3 Shlomo Hershkop shlomo@cs.columbia.edu 1 Outline Intro CPP Boring stuff: Language basics: identifiers, data types, operators, type conversions, branching
More informationIBM i Version 7.2. Programming IBM Rational Development Studio for i ILE C/C++ Language Reference IBM SC
IBM i Version 7.2 Programming IBM Rational Development Studio for i ILE C/C++ Language Reference IBM SC09-7852-03 IBM i Version 7.2 Programming IBM Rational Development Studio for i ILE C/C++ Language
More informationcs3157: c++ lecture #2 (mon-11-apr-2005) chronology of some programming languages... C++ vs Java identifiers.
cs3157: c++ lecture #2 (mon-11-apr-2005) chronology of some programming languages... today: language basics: identifiers, data types, operators, type conversions, branching and looping, program structure
More informationProgramming in C++ 4. The lexical basis of C++
Programming in C++ 4. The lexical basis of C++! Characters and tokens! Permissible characters! Comments & white spaces! Identifiers! Keywords! Constants! Operators! Summary 1 Characters and tokens A C++
More informationW3101: Programming Languages C++ Ramana Isukapalli
Lecture-6 Operator overloading Namespaces Standard template library vector List Map Set Casting in C++ Operator Overloading Operator overloading On two objects of the same class, can we perform typical
More informationSECTION 5 L1 - Group By and Having Clauses
SECTION 5 L1 - Group By and Having Clauses Clauza Group By 1. SELECT department_id, AVG(salary),MAX(salary) 2. SELECT job_id, last_name, AVG(salary) GROUP BY job_id; ORA-00979: not a GROUP BY expression
More informationComputers Programming Course 6. Iulian Năstac
Computers Programming Course 6 Iulian Năstac Recap from previous course Data types four basic arithmetic type specifiers: char int float double void optional specifiers: signed, unsigned short long 2 Recap
More informationPractical C++ Programming
SECOND EDITION Practical C++ Programming Steve Oualline O'REILLY' Beijing Cambridge Farnham Koln Paris Sebastopol Taipei Tokyo Preface xv Part I. The Basics 1. What Is C++? 3 A Brief History of C++ 3 C++
More informationCSCI 123 Introduction to Programming Concepts in C++
CSCI 123 Introduction to Programming Concepts in C++ Brad Rippe C++ Basics C++ layout Include directive #include using namespace std; int main() { } statement1; statement; return 0; Every program
More informationWelcome to Teach Yourself Acknowledgments Fundamental C++ Programming p. 2 An Introduction to C++ p. 4 A Brief History of C++ p.
Welcome to Teach Yourself p. viii Acknowledgments p. xv Fundamental C++ Programming p. 2 An Introduction to C++ p. 4 A Brief History of C++ p. 6 Standard C++: A Programming Language and a Library p. 8
More informationCh. 3: The C in C++ - Continued -
Ch. 3: The C in C++ - Continued - QUIZ What are the 3 ways a reference can be passed to a C++ function? QUIZ True or false: References behave like constant pointers with automatic dereferencing. QUIZ What
More informationChapter 2
Chapter 2 Topic Contents The IO Stream class C++ Comments C++ Keywords Variable Declaration The const Qualifier The endl, setw, setprecision, manipulators The scope resolution operator The new & delete
More informationProgramarea calculatoarelor
Programarea calculatoarelor #3 C++ Elemente introductive ale limbajului C++ 2016 Adrian Runceanu www.runceanu.ro/adrian Curs 3 Elemente introductive ale limbajului C++ 02.11.2016 Curs - Programarea calculatoarelor
More informationInformation Science 1
Information Science 1 Simple Calcula,ons Week 09 College of Information Science and Engineering Ritsumeikan University Topics covered l Terms and concepts from Week 8 l Simple calculations Documenting
More informationCSC 1214: Object-Oriented Programming
CSC 1214: Object-Oriented Programming J. Kizito Makerere University e-mail: jkizito@cis.mak.ac.ug www: http://serval.ug/~jona materials: http://serval.ug/~jona/materials/csc1214 e-learning environment:
More informationExpressions and Data Types CSC 121 Spring 2015 Howard Rosenthal
Expressions and Data Types CSC 121 Spring 2015 Howard Rosenthal Lesson Goals Understand the basic constructs of a Java Program Understand how to use basic identifiers Understand simple Java data types
More informationArithmetic Operators. Portability: Printing Numbers
Arithmetic Operators Normal binary arithmetic operators: + - * / Modulus or remainder operator: % x%y is the remainder when x is divided by y well defined only when x > 0 and y > 0 Unary operators: - +
More informationBasic program The following is a basic program in C++; Basic C++ Source Code Compiler Object Code Linker (with libraries) Executable
Basic C++ Overview C++ is a version of the older C programming language. This is a language that is used for a wide variety of applications and which has a mature base of compilers and libraries. C++ is
More informationCS2141 Software Development using C/C++ C++ Basics
CS2141 Software Development using C/C++ C++ Basics Integers Basic Types Can be short, long, or just plain int C++ does not define the size of them other than short
More information1. Funcţii referitoare la o singură înregistrare (single-row functions)
Laborator 4 Limbajul SQL 1. Funcţii referitoare la o singură înregistrare (single-row functions) 2. Funcţii referitoare la mai multe înregistrări (multiple-row functions) 1. Funcţii referitoare la o singură
More informationLESSON 1. A C program is constructed as a sequence of characters. Among the characters that can be used in a program are:
LESSON 1 FUNDAMENTALS OF C The purpose of this lesson is to explain the fundamental elements of the C programming language. C like other languages has all alphabet and rules for putting together words
More informationOperators. The Arrow Operator. The sizeof Operator
Operators The Arrow Operator Most C++ operators are identical to the corresponding Java operators: Arithmetic: * / % + - Relational: < = >!= Logical:! && Bitwise: & bitwise and; ^ bitwise exclusive
More informationFundamentals of Programming
Fundamentals of Programming Lecture 3 - Constants, Variables, Data Types, And Operations Lecturer : Ebrahim Jahandar Borrowed from lecturer notes by Omid Jafarinezhad Outline C Program Data types Variables
More informationError! Bookmark not defined.
SEMINAR 06 CONTENTS Enuntul Problemei... 1 Repository... 2 Memory... 2 XML... 3 GUI... 4 Forma Selectie... 4 Forma Programator... 5 Forma Tester... 6 Java... 7 Mecanismul de Transmitere al Evenimentelor
More informationThe University of Nottingham
The University of Nottingham SCHOOL OF COMPUTER SCIENCE A LEVEL 2 MODULE, AUTUMN SEMESTER 2009-2010 C/C++ for Java Programmers Time allowed TWO hours Candidates may complete the front cover of their answer
More informationPIC 10A Pointers, Arrays, and Dynamic Memory Allocation. Ernest Ryu UCLA Mathematics
PIC 10A Pointers, Arrays, and Dynamic Memory Allocation Ernest Ryu UCLA Mathematics Pointers A variable is stored somewhere in memory. The address-of operator & returns the memory address of the variable.
More informationBasic operators, Arithmetic, Relational, Bitwise, Logical, Assignment, Conditional operators. JAVA Standard Edition
Basic operators, Arithmetic, Relational, Bitwise, Logical, Assignment, Conditional operators JAVA Standard Edition Java - Basic Operators Java provides a rich set of operators to manipulate variables.
More informationChapter 7. Additional Control Structures
Chapter 7 Additional Control Structures 1 Chapter 7 Topics Switch Statement for Multi-Way Branching Do-While Statement for Looping For Statement for Looping Using break and continue Statements 2 Chapter
More informationUEE1302 (1102) F10: Introduction to Computers and Programming
Computational Intelligence on Automation Lab @ NCTU Learning Objectives UEE1302 (1102) F10: Introduction to Computers and Programming Programming Lecture 00 Programming by Example Introduction to C++ Origins,
More informationIngineria Sistemelor de Programare. UML Diagrama Cazurilor de Utilizare 2016
Ingineria Sistemelor de Programare UML Diagrama Cazurilor de Utilizare mihai.hulea@aut.utcluj.ro 2016 Introducere UML UML UML = Unified Modeling Language Dezvoltat in cadrul Object Management Group In
More informationCHAPTER 1 Introduction to Computers and Programming CHAPTER 2 Introduction to C++ ( Hexadecimal 0xF4 and Octal literals 031) cout Object
CHAPTER 1 Introduction to Computers and Programming 1 1.1 Why Program? 1 1.2 Computer Systems: Hardware and Software 2 1.3 Programs and Programming Languages 8 1.4 What is a Program Made of? 14 1.5 Input,
More informationBasic C Programming (2) Bin Li Assistant Professor Dept. of Electrical, Computer and Biomedical Engineering University of Rhode Island
Basic C Programming (2) Bin Li Assistant Professor Dept. of Electrical, Computer and Biomedical Engineering University of Rhode Island Data Types Basic Types Enumerated types The type void Derived types
More informationUnit-2 (Operators) ANAND KR.SRIVASTAVA
Unit-2 (Operators) ANAND KR.SRIVASTAVA 1 Operators in C ( use of operators in C ) Operators are the symbol, to perform some operation ( calculation, manipulation). Set of Operations are used in completion
More informationNivelul inferior de prelucrare a fişierelor
INTRĂRI ŞI IEŞIRI Operaţiile de I/E în limbajul C se realizează prin intermediul unor funcţii din biblioteca standard a limbajului. Majoritatea operaţiilor de I/E se realizează în ipoteza că datele sunt
More informationXC Specification. 1 Lexical Conventions. 1.1 Tokens. The specification given in this document describes version 1.0 of XC.
XC Specification IN THIS DOCUMENT Lexical Conventions Syntax Notation Meaning of Identifiers Objects and Lvalues Conversions Expressions Declarations Statements External Declarations Scope and Linkage
More information