Skip to content

Commit

Permalink
0.5.0
Browse files Browse the repository at this point in the history
Changed LICENSE from restrictive GPL to permissive MIT
  • Loading branch information
quantum-leaps committed Apr 25, 2023
1 parent 7aeda01 commit 90c6905
Show file tree
Hide file tree
Showing 20 changed files with 357 additions and 951 deletions.
695 changes: 21 additions & 674 deletions LICENSE

Large diffs are not rendered by default.

34 changes: 21 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,44 +1,45 @@
## Brought to you by:
[![Quantum Leaps](https://www.state-machine.com/attachments/logo_ql_400.png)](https://www.state-machine.com)
<hr>

---------------------------------------------------------------------
[![Object-Oriented Programming in C](img/thumbnail.jpg)](https://www.state-machine.com/oop)
[![GitHub release (latest by date)](https://img.shields.io/github/v/release/QuantumLeaps/OOP-in-C)](https://github.com/QuantumLeaps/OOP-in-C/releases/latest)
[![GitHub](https://img.shields.io/github/license/QuantumLeaps/OOP-in-C)](https://github.com/QuantumLeaps/OOP-in-C/blob/master/LICENSE)

# The Accompanying Code

# Object-Oriented Programming in C
This repository provides the code accompanying the article:
["Object-Oriented Programming"](https://www.state-machine.com/oop).
The code can be compiled and executed on any desktop
computer (running Windows, Linux, or macOS).

<p align="center"><img src="img/thumbnail.jpg"/></p>

Here is the code structure:

```
OOP-in-C
+---doc
OOP-in-C/
+---doc/
¦ AN_OOP_in_C.pdf
¦
+---encapsulation
+---encapsulation/
¦ main.c
¦ make.bat
¦ oop_in_c.exe
¦ shape.c
¦ shape.h
¦
+---inheritance
+---inheritance/
¦ main.c
¦ make.bat
¦ oop_in_c.exe
¦ rect.c
¦ rect.h
¦ shape.c
¦ shape.h
¦
+---polymorphism
+---polymorphism/
circle.c
circle.h
main.c
make.bat
oop_in_c.exe
rect.c
rect.h
shape.c
Expand Down Expand Up @@ -75,13 +76,20 @@ The concepts of OOP in C have been explained in a series of videos:


# The PDF Version
The PDF version of the
["Object-Oriented Programming" article](https://www.state-machine.com/oop)
The PDF version of the
["Object-Oriented Programming" article](doc/AN_OOP_in_C.pdf)
is provided in the directory `doc`

[![Object-Oriented Programming in C](img/AN_OOP-in-C.jpg)](doc/AN_OOP_in_C.pdf)


# Licensing
The OOP-in-C source code and examples are released under the terms of the
permissive [MIT open source license](LICENSE). Please note that the
attribution clause in the MIT license requires you to preserve the
original copyright notice in all changes and derivate works.


# How to Help this Project?
If you like this project, please give it a star (in the upper-right corner of your browser window):

Expand Down
39 changes: 21 additions & 18 deletions encapsulation/main.c
Original file line number Diff line number Diff line change
@@ -1,27 +1,30 @@
/*****************************************************************************
* Code accompanying the Application Note:
/*============================================================================
* Code accompanying the Article:
* "Object-Oriented Programming in C"
* https://www.state-machine.com/doc/AN_OOP_in_C.pdf
* https://github.com/QuantumLeaps/OOP-in-C
*
* Copyright (C) 2005-2018 Quantum Leaps. All Rights Reserved.
* Copyright (C) 2006-2023 Quantum Leaps, <state-machine.com>.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* SPDX-License-Identifier: MIT
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* Contact Information:
* https://www.state-machine.com
****************************************************************************/

* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
============================================================================*/
#include "shape.h" /* Shape class interface */
#include <stdio.h> /* for printf() */

Expand Down
Binary file removed encapsulation/oop_in_c.exe
Binary file not shown.
39 changes: 21 additions & 18 deletions encapsulation/shape.c
Original file line number Diff line number Diff line change
@@ -1,27 +1,30 @@
/*****************************************************************************
* Code accompanying the Application Note:
/*============================================================================
* Code accompanying the Article:
* "Object-Oriented Programming in C"
* https://www.state-machine.com/doc/AN_OOP_in_C.pdf
* https://github.com/QuantumLeaps/OOP-in-C
*
* Copyright (C) 2005-2018 Quantum Leaps. All Rights Reserved.
* Copyright (C) 2006-2023 Quantum Leaps, <state-machine.com>.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* SPDX-License-Identifier: MIT
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* Contact Information:
* https://www.state-machine.com
****************************************************************************/

* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
============================================================================*/
#include "shape.h" /* Shape class interface */

/* constructor implementation */
Expand Down
38 changes: 21 additions & 17 deletions encapsulation/shape.h
Original file line number Diff line number Diff line change
@@ -1,26 +1,30 @@
/*****************************************************************************
* Code accompanying the Application Note:
/*============================================================================
* Code accompanying the Article:
* "Object-Oriented Programming in C"
* https://www.state-machine.com/doc/AN_OOP_in_C.pdf
* https://github.com/QuantumLeaps/OOP-in-C
*
* Copyright (C) 2005-2017 Quantum Leaps. All Rights Reserved.
* Copyright (C) 2006-2023 Quantum Leaps, <state-machine.com>.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* SPDX-License-Identifier: MIT
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* Contact Information:
* https://www.state-machine.com
****************************************************************************/
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
============================================================================*/
#ifndef SHAPE_H
#define SHAPE_H

Expand Down
39 changes: 21 additions & 18 deletions inheritance/main.c
Original file line number Diff line number Diff line change
@@ -1,27 +1,30 @@
/*****************************************************************************
* Code accompanying the Application Note:
/*============================================================================
* Code accompanying the Article:
* "Object-Oriented Programming in C"
* https://www.state-machine.com/doc/AN_OOP_in_C.pdf
* https://github.com/QuantumLeaps/OOP-in-C
*
* Copyright (C) 2005-2018 Quantum Leaps. All Rights Reserved.
* Copyright (C) 2006-2023 Quantum Leaps, <state-machine.com>.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* SPDX-License-Identifier: MIT
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* Contact Information:
* https://www.state-machine.com
****************************************************************************/

* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
============================================================================*/
#include "rect.h" /* Rectangle class interface */
#include <stdio.h> /* for printf() */

Expand Down
Binary file removed inheritance/oop_in_c.exe
Binary file not shown.
39 changes: 21 additions & 18 deletions inheritance/rect.c
Original file line number Diff line number Diff line change
@@ -1,27 +1,30 @@
/*****************************************************************************
* Code accompanying the Application Note:
/*============================================================================
* Code accompanying the Article:
* "Object-Oriented Programming in C"
* https://www.state-machine.com/doc/AN_OOP_in_C.pdf
* https://github.com/QuantumLeaps/OOP-in-C
*
* Copyright (C) 2005-2017 Quantum Leaps. All Rights Reserved.
* Copyright (C) 2006-2023 Quantum Leaps, <state-machine.com>.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* SPDX-License-Identifier: MIT
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* Contact Information:
* https://www.state-machine.com
****************************************************************************/

* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
============================================================================*/
#include "rect.h"

/* constructor implementation */
Expand Down
38 changes: 21 additions & 17 deletions inheritance/rect.h
Original file line number Diff line number Diff line change
@@ -1,26 +1,30 @@
/*****************************************************************************
* Code accompanying the Application Note:
/*============================================================================
* Code accompanying the Article:
* "Object-Oriented Programming in C"
* https://www.state-machine.com/doc/AN_OOP_in_C.pdf
* https://github.com/QuantumLeaps/OOP-in-C
*
* Copyright (C) 2005-2017 Quantum Leaps. All Rights Reserved.
* Copyright (C) 2006-2023 Quantum Leaps, <state-machine.com>.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* SPDX-License-Identifier: MIT
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* Contact Information:
* https://www.state-machine.com
****************************************************************************/
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
============================================================================*/
#ifndef RECT_H
#define RECT_H

Expand Down
Loading

0 comments on commit 90c6905

Please sign in to comment.