0% found this document useful (0 votes)
7 views8 pages

Data Storage Concepts in C++

The document discusses data storage in C++, explaining its types, methods, and how it operates within the programming language. It covers direct area storage, network-based storage, and the various forms of data storage such as file, block, and object storage. Additionally, it details memory management in C++ using stack and heap, along with the use of new and delete operators for dynamic memory allocation.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views8 pages

Data Storage Concepts in C++

The document discusses data storage in C++, explaining its types, methods, and how it operates within the programming language. It covers direct area storage, network-based storage, and the various forms of data storage such as file, block, and object storage. Additionally, it details memory management in C++ using stack and heap, along with the use of new and delete operators for dynamic memory allocation.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

NAME:

JOHNSON IFEOLUWA OLUWASEGUNFUNMI


SCHOOL:
THE CARDINAL HIGH SCHOOL
CLASS:
SS3
SUBJECT:
COMPUTER SCIENCE
PROJECT TITLE:
DATA STORAGE IN C++
INSTRUCTOR:
MR VICTOR
DATA STORAGE IN C++

DATA STORAGE:
Data storage refers to magnetic, optical or mechanical
media that record and preserve digital information for
ongoing or future operations. There are two types of digital
information: input and output data. Users provide the input
data, and computers provide the output data. However, a
computer's CPU can’t compute anything or produce output
data without the user's input.
Users can enter the input data directly into a computer.
However, early on in the computer era, they found that
continually entering data manually is time- and energy-
prohibitive. One short-term solution is computer memory,
also known as random access memory (RAM). However, its
storage capacity and memory retention are limited. Read-
only memory (ROM) is, as the name suggests, where data
can only be read but not necessarily edited. It controls a
computer's basic functions.
HOW DOES DATA STORAGE WORK?
Modern computers or terminals connect to storage devices
either directly or through a network. Users instruct
computers to access data from and store data on these
storage devices. However, at a fundamental level, there
are two foundations to data storage: the form in which data
is taken and the devices on which it is recorded and stored.
Data storage devices come in two main categories: direct
area storage and network-based storage:
1. Direct Area Storage: Direct Area Storage or Direct-
Attached Storage is often in the immediate area and
directly connected to the computing machine
accessing it. Often, it's the only machine connected to
it. DAS can also provide decent local backup services,
but sharing is limited. DAS devices include diskettes,
optical discs—compact discs (CDs) and digital video
discs (DVDs)—hard disk drives (HDD), flash drives and
solid-state drives (SSD).

2. Network-Based Storage: network-based


storage allows multiple computers to access it through
a network, making it better for data sharing and
collaboration. Its off-site storage capability is also
better suited for backups and data protection. Two
standard network-based storage setups are network-
attached storage (NAS) and storage area network
(SAN). NAS is often a single device made up of
redundant storage containers or a redundant array of
independent disks (RAID). SAN storage can be a
network of multiple devices of various types, including
SSD and flash storage, hybrid storage, hybrid cloud
storage, cloud storage and backup software and
appliances.

FORMS OF DATA STORAGE

Data can be recorded and stored in three primary


forms: file storage, block storage and object storage.

 FILE STORAGE:

File storage, or file-based storage, is a


hierarchical storage methodology used to organize
and store data. In other words, data is stored in files,
which are organized in folders, which are organized
under a hierarchy of directories and subdirectories.

 BLOCK STORAGE:

Block storage, sometimes called block-level


storage, is a technology for storing data in blocks. The
blocks are then stored as separate pieces, each with a
unique identifier. Developers favour block storage for
computing situations that require fast, efficient and
reliable data transfer.

 OBJECT STORAGE

Object storage, often called object-based storage,


is a data storage architecture for handling large
amounts of unstructured data. This data doesn't
conform to—or can't be organized easily into—a
traditional relational database with rows and columns.
Examples include email, videos, photos, web pages,
audio files, sensor data and other media and web
content (textual or non-textual). Other use cases
include building cloud-native applications or
transforming legacy applications into next-generation
cloud applications by using cloud-based object storage
as a persistent data store.

DATA TYPES

C++ has several data types that can be used to store


integers; we will mainly use int that is for numbers. We will
use char for characters. Note that, one can treat a char as
an integer for arithmetic. C++ has several data types that
can be used to store floating-point numbers; we will almost
always use double. There is also bool for Boolean (that is,
true or false); sometimes integers are substituted, where 0
means false and anything non-zero means true. So, we
use:

1. Int for integers that is numbers without


quotation marks
2. Char for string that is words and letters
3. Bool that is Boolean (true or false)
4. Double that is for float (decimal numbers)

ARRAYS
Arrays in C++ are declared to hold a specific number of the
same type of object. The valid indices are 0 up to 1 less
than the size of the array. The execution does no checking
for references going outside the bounds of the array.
Arrays can be initialized at declaration.

FUNCTIONS

A function is a self-standing piece of code. It can return a


variable of a specified type, or have type void. It can have
arguments of specific type. In general, variables are passed
by value, which means that the function receives a copy of
the variable. This is inefficient for large objects, so these
are usually passed by address (such as automatically
occurs for arrays) or by reference.

To aid the compiler, a prototype of a function at the start of


a program tells the compiler of the existence of such a
function: it specifies the name, arguments, and type of the
function. The actual names of the arguments are optional,
but recommended.

POINTERS

A pointer stores an address. A pointer has a type: this

the pointer points. A pointer is defined using the ∗, and is


indicates the type of object stored at the address to which

dereferenced thereby too. An array name is equivalent to a


pointer to the start of that array. Primitive arithmetic can
be applied to pointers. To indicate that a pointer points to
nothing, it is set equal to “nullptr”.

HOW DATA IS STORED AND ORGANISED IN C++

In C++, the memory can be allocated at runtime and


deallocate it when not required. With this feature, we get
the flexibility of allocation and deallocation of memory as
per requirement. In this article on C++ memory
management, we will learn about the dynamic allocation of
memory and understand its working in detail. Sometimes,
the computer’s data can range up to terabytes, so efficient
use of memory is necessary to minimize memory wastage
and boost up performance. The memory that a C++
program uses is divided into different parts. Here, we will
discuss two, i.e., stack and heap.

 Stack: In stack, all the variables that are declared


inside the function and other information related to
the function are stored.
 Heap: Heap is unused memory and the part from
where the memory is allocated dynamically when the
program runs.

In C++, two operators are used for the allocation and


deallocation of memory i.e.

 New operator
 Delete operator

C++ NEW OPERATOR: Using the C++ new operator, we


can allocate memory at the runtime. The new operator in
C++ is used for the dynamic memory allocation; It is used
to allocate the memory at runtime on heap memory.

C++ DELETE OPERATOR:

Once the memory is allocated, we can delete the memory


when it is not required anymore. The delete operator in C+
+ is used for the deallocation of memory.
When we no longer need to use the variable, that means
when the memory is no longer required, we have to
deallocate or release the memory using the delete
operator. Here we see that after the using and re-using of
the variable (data store) the delete operator is deleted.

CONCLUSION

Data storage in C++ is very easy to understand and operate


as it mostly in form of “stack and heap” method. There are
still numerous data storage methods and data structures in
the programming language like:

1. Objects (which still has other characteristics


like polymorphism and inheritance like other
languages like python and java)
2. Constructors
3. Data Members and Member Functions

The data structures have some things in common with


other programming languages like python and java. This
makes it easier for programmers to compare, contrast and
combine programs of similar projects even when they are
in different languages thereby, enhancing easy
collaboration.

REFERENCES
[Link]
Public/storageModels/[Link]\

[Link]

[Link]

You might also like