User Tools

Site Tools


Sidebar

projects

ntr0 (due 20220119)
pct1 (bonus; due 20220119)
wcp1 (due 20220119)
fwf0 (due 20220126)
pct2 (due 20220126)
wcp2 (due 20220126)
pct3 (bonus; due 20220202)
sof0 (due 20220202)
wcp3 (due 20220202)
dow0 (due 20220209)
pct4 (due 20220209)
wcp4 (due 20220209)
cbf0 (due 20220216)
gfo0 (due 20220216)
pct5 (bonus; due 20220216)
wcp5 (due 20220216)
bwp1 (bonus; due 20220302)
pct6 (due 20220302)
wcp6 (due 20220302)
cnv0 (due 20220309)
pct7 (bonus; due 20220309)
wcp7 (due 20220309)
cnv1 (due 20220316)
pct8 (due 20220316)
wcp8 (due 20220316)
cos0 (due 20220323)
gfo1 (due 20220323)
pct9 (bonus; due 20220323)
wcp9 (due 20220323)
bwp2 (bonus; due 20220406)
pctA (due 20220406)
sam0 (due 20220406)
wcpA (due 20220406)
oop0 (due 20220413)
pctB (bonus; due 20220413)
wcpB (due 20220413)
oop1 (due 20220420)
pctC (due 20220420)
wcpC (due 20220420)
oop2 (due 20220427)
pctD (bonus; due 20220427)
wcpD (bonus; due 20220427)
gfo2 (due 20220504)
pctE (bonus; due 20220504)
wcpE (bonus; due 20220504)
EoCE (due 20220512)
haas:spring2022:cprog:projects:oop0

Corning Community College

CSCS1320 C/C++ Programming

PROJECT: Object-Oriented Programming (OOP0)

Objective

Collaborate in the creation of a useful, originally-voiced informational source on the basics of C++ programming, specifically the creation of classes and instantiation of objects, and the implementation of a simple program that has and uses a class.

The idea is to demonstrate your skills gained throughout the semester, by harnessing new concepts and problem solving experiences to delve into this new area of the course: C++ and object-oriented programming.

C++

Backstory of C++ Programming language

Backstory and motivation of its creation

In the 1960s-1990s many computer programming languages were being created for different purposes, but most of them had flaws. Some languages were easy to understand, but lacked the depth to accomplish more difficult tasks. Others had this capability, but were large, abstract, and very difficult to learn, thus leading people to create more with the goal of having a language that was not too complex, but could effectively complete difficult tasks. This eventually led to a C language that was good for low level programming, and a SIMULA language that had a class system. C++ language was the creation of Bjarne Stroustrup that combined these two.

Differences between C and C++ language

The main difference between the two is that C is a procedural programming language, whereas C++ is a hybrid language that can perform both procedural and object oriented programming. C supports built in data types, whereas C++ can support both built-in and user defined data types. C has 32 keywords, whereas C++ has 63 keywords, and C++ supports far more things in general than C. From a security standpoint, C does not support encapsulation so data can be manipulated by outside code meanwhile C++ supports encapsulation so the data is hidden.

Why C++ is still being updated today

C++ is still updated today because it is still so widely used today, due to its speed, programming capability, and its continued popularity in being used (even if a superior language did come out computer scientists would still have to learn that new language, and languages already written in C++ would still be written in C++).

Common uses of C++ in current times

C++ is most notably used in the creation of high performance programs, such as video games, operating systems, and the Google Chrome and Firefox web browsers.

Cool bug facts:

C++ is a play on the ++ increment operator in C language.

C++ was originally called 'The New C'.

C++ has influenced other programming languages such as C# and Java.

OOP

Object Oriented Programming refers to a type of programming that uses objects that contain both data and functions. This is opposed to procedural programming, which is about writing procedures or functions that perform operations. OOP has several advantages over Procedural Programming which include:

OOP is faster and easier to execute. OOP provides clear structure for programs. OOP helps make code easier to maintain, modify and debug. OOP makes it possible to create reusable applications with less code and a shorter development time.

Classes

User defined data types. Classes make it easier to work with data by providing users with the ability to create constructors, destructors, member data, member functions, and more.

Member Data

In C++, you can define data inside of classes for the sake of using them with member functions. Access specifiers can be used to determine where these variables can be called from, and which functions can call them. (This is further described down below)

Methods (Member Functions)

Methods are functions that belong to a class. The two ways to define a function that belongs to a class are inside the class definition and outside the class definition. In order to define a method outside the class definition, you must first declare it inside the class. You can then define your function outside of the class by specifying the name of the class and following it with the “::” operator. These functions are meant to be used alongside member data.

Constructors

Constructors are functions that are called when an object is created. They can be used with or without parameters, similarly to any other type of function. They do not return any values.

Destructors

Destructors are special functions that are called in any of the below conditions:

(1) the function ends (2) the program ends (3) a block containing local variables ends (4) a delete operator is called

They are meant to be used when a pointer is used in a class, or when memory has been dynamically allocated, in order to prevent memory leakage.

Classes as Value/Reference types

C++ classes are by default value types. Value types typically deal with memory or layout control, whereas, reference types are related to base classes and virtual functions for polymorphic purposes. A difference between the two types, is that value types are copyable, meaning, there is a copy constructor and copy assignment operator. Reference types on the other hand, make the class non-copyable, using a virtual destructor. Changing the class type is something that is done by the user/programmer, and is done by disabling the copy constructor and copy assignment operator. In short value types are about creating two values that can each be modified, whereas, reference types are more about identity.

Access Control

Public

Public members can be accessed in any part of the program.

Private

Private members can only be accessed by members of the same class.

Protected

Protected members can be accessed by members of the same class, friend classes, and derived classes

Structs vs Classes

Struct members are public by default. Class members are private by default.

Inheritance

Single inheritance is when one class inherits directly from one other class. This is typical for most classes. Public inheritance does not change in subclasses from the parent class. Protected inheritance refers to when anything higher than protected will be protected. Both public and protected properties will be protected in a subclass. Private inheritance takes this a step further as all three inheritance types will be made private in a subclass.

Objects

Instances of a class. Creating an object of a class works almost exactly like initializing any fundamental type; simply specify the the type name, followed by your variable's name. Objects are introduced by declarations.

Program

Write a program that creates one or more of the following classes:

  • rectangle
  • triangle
  • trapezoid

That contains, in addition to at least 2 constructors (parameterless, and a parametered), the following public member functions:

  • getLength()
  • getWidth()
  • setLength()
  • setWidth()
  • area()
  • perimeter()

Store length, width, and any other pertinent core values as private, accessible only from the public member functions.

Have a main() function that instantiates an instance of your chosen shape class, and runs that instantiated object through a range of tests demonstrating the class works as intended (likely also prompting the user to input values to configure the attributes of the object).

References

Submission

I'll be looking for the following:

104:oop0:final tally of results (104/104)
*:oop0:no compiler messages, program compiles and runs without issue [52/52]
*:oop0:specified functionality is implemented [52/52]

Additionally:

  • Solutions not abiding by SPIRIT of project will be subject to a 50% overall deduction
  • Solutions not utilizing descriptive why and how COMMENTS will be subject to a 50% overall deduction
  • Solutions not utilizing INDENTATION to promote scope and clarity will be subject to a 50% overall deduction
  • Solutions lacking ORGANIZATION and are not easy to read (within 90 char width) are subject to a 50% overall deduction
haas/spring2022/cprog/projects/oop0.txt · Last modified: 2022/04/07 16:01 by wedge