jagomart
digital resources
picture1_Concepts Of Programming Languages Pdf 186907 | Classes


 168x       Filetype PDF       File size 1.51 MB       Source: cs.au.dk


File: Concepts Of Programming Languages Pdf 186907 | Classes
object orientedprogramming classes objects self construction encapsulation object orientedprogramming programming paradigm exampleof otherparadigmsarefunctional programmingwherethe focusis on functions lambda sand higher order functions and imperative programming focusing on sequences of statements ...

icon picture PDF Filetype PDF | Posted on 02 Feb 2023 | 2 years ago
Partial capture of text on file.
    C++ Classes and Object 
    Oriented Programming
     CPSC 1070, Donald House, Clemson University

              10/21/19
            Some C code for handling 
                                       2D points
         #include                              int main(){ 
                                                          Point p1; 
         typedef struct point{                            Point p2; 
           int x, y;                                      int nx, ny; 
         } Point;                                         int dx, dy; 
         void setpoint(Point *p, int x0, int y0){         printf("Enter p1: "); 
           p->x = x0;                                     scanf("%d %d", &nx, &ny); 
                                                          setpoint(&p1, nx, ny); 
           p->y = y0;                                      
         }                                                printf("Enter p2: "); 
                                                          scanf("%d %d", &nx, &ny); 
         void movepoint(Point *p, int dx, int dy){        setpoint(&p2, nx, ny); 
           p->x += dx;                                    printpoint(&p1); 
           p->y += dy;                                    printf(", "); 
         }                                                printpoint(&p2); 
                                                          printf("\n"); 
         void printpoint(Point *p){                        
           printf("(%d, %d)", p->x, p->y);                printf("Enter p2 changes: "); 
         }                                                while(scanf("%d %d", &dx, &dy) == 2){ 
                                                            movepoint(&p2, dx, dy); 
                                                            printpoint(&p2); 
                                                            printf("\n"); 
                                                          } 
                                                           
                                                          return 0; 
                                                        }
      Critique of Point Code
     The data structure:

     typedef struct point{ 
       int x, y; 
     } Point; 
     Is defined separately from the functions operating on the data:

     void setpoint(Point *p, int x0, int y0); 
     void movepoint(Point *p, int dx, int dy); 
     void printpoint(Point *p); 
     Also, pointers to the Point need to be passed around, and the 
     functions need to be named to explicitly work on Points:

     setpoint(&p2, nx, ny); 
     C++ remedies this by providing for classes, which are designed to 
     package data structures with methods that operate on the data.
     Some Nomenclature
   • Class is a type whose description consists of declarations 
    and definitions for both a data structure and operations 
    on that data structure

   • Method is an operation (i.e. a function) defined for a class

   • Class Declaration: declarations for a data structure, and a 
    set of methods that operate on the data structure.

   • Class Definition: definitions (i.e. the actual code) for the 
    set of methods for the class.

   • Object is a variable of a given class
The words contained in this file might help you see if this file matches what you are looking for:

...Object orientedprogramming classes objects self construction encapsulation programming paradigm exampleof otherparadigmsarefunctional programmingwherethe focusis on functions lambda sand higher order and imperative focusing sequences of statements changing the state program supportedby manyprogramminglanguages includingpython core concepts are methods allowing one to construct abstract data types i e user defined where have states can manipulate these defining interface rest oriented history selected languages mid s simular ole johan dahl kristen nygaard norsk regnesentral oslo introduced virtual procedures smalltalk alan kay dan ingalls adele goldberg xerox parc fully dynamic system opposed static nature simula eiffel bertrand meyer software focus quality capturing full cycle c bjarne stroustrup at t bell labs java james gosling sun anders hejlsberg studied dtu et al microsoft python guido van rossum byte magazine multi language august note among top tiobe january index popular only n...

no reviews yet
Please Login to review.