This document provides information about a lecture on data structures. It introduces the lecturer, Fazl-e-Basit, including their education and work experience. It then outlines the objectives of the course, which are to cover common data structures like arrays, lists, stacks and queues, and teach how to implement these structures in C++. Finally, it discusses the teaching procedures, materials, grading breakdown, keys for success and pointers.
A recursive function is a function that calls itself. A recursive function is used for repeating code. If the state of the function does not change, and it has no preset exit condition that is reached, a recursive call can turn into an infinite loop.
A recursive function is a function that calls itself. A recursive function is used for repeating code. If the state of the function does not change, and it has no preset exit condition that is reached, a recursive call can turn into an infinite loop.
What attracts researchers starting from the 60s till nowadays? What is studied in university by engineers in computer science and then successfully forgotten? What is at the heart of the compilers used daily by any software developer? Parsers! From a practical point of view using a small pill of theory, this session will bring lights on questions like: if there is so many parser-generators based on formal theory, then why javac, GCC and Clang are all hand-written? And how we, insiders of the world of parsing, do this at SonarSource for languages like Java, C/C++, C#, JavaScript, Python, COBOL?
This presentation is a part of the COP2272C college level course taught at the Florida Polytechnic University located in Lakeland Florida. The purpose of this course is to introduce students to the C++ language and the fundamentals of object orientated programming..
The course is one semester in length and meets for 2 hours twice a week. The Instructor is Dr. Jim Anderson.
The second lecture of expert system with python course.
Enjoy!
you can find the first lecture here:
https://www.slideshare.net/ahmadhussein45/expert-system-with-python-1
C++ CoreHard Autumn 2018. Concurrency and Parallelism in C++17 and C++20/23 -...corehard_by
What do threads, atomic variables, mutexes, and conditional variables have in common? They are the basic building blocks of any concurrent application in C++, which are even for the experienced C++ programmers a big challenge. This massively changed with C++17 and change even more with C++20/23. What did we get with C++17, what can we hope for with C++20/23? With C++17, most of the standard template library algorithms are available in sequential, parallel, and vectorised variants. With the upcoming standards, we can look forward to executors, transactional memory, significantly improved futures and coroutines. To make it short. These are just the highlights from the concurrent and parallel perspective. Thus there is the hope that in the future C++ abstractions such as executors, transactional memory, futures and coroutines are used and that threads, atomic variables, mutexes and condition variables are just implementation details.
Analysis of Haiku Operating System (BeOS Family) by PVS-Studio. Part 1PVS-Studio
Operating systems are among the largest and most complicated software projects, and that means they perfectly suit the purpose of demonstrating static code analysis' capabilities. After the successful analysis of Linux Kernel, I felt inspired to try analyzing other open-source operating systems as well.
This Presentation gives you all knowledge about #CPointers, #PointersInC.
The given slides are as follows:
1. Introduction of Pointers.
2. Systems to create a pointer in C.
3. Valid Pointer Examples in C.
4. Graphical representation of address assigning in c using pointer.
5. 1st Sample program of pointers in C.
6. Types of Pointers
7. NULL Pointer in C (Types of Pointer)
8. void Pointer in C (Types of Pointer)
9. Wild Pointer in C (Types of Pointer)
10. Changing value of variable using pointer
11. Update and Access value of variable using pointer in example.
12. Types of format specifies to print address in different format.
13. Advantages of Pointer in C.
14. Disadvantages of Pointer in C.
15. Pointers with Array using Programs. #pointerwitharray
16. Another Example of #pointerwitharray.
17. Relationship Between Arrays and Pointers.
18. Relationship Between Arrays and Pointers explanation with diagram.
19. Pointers and String. #PointersAndString
20. Function with Array Parameters using pointers.
21. Passing Pointers to Function or Pointer argument function. #PointerWithFunction
What attracts researchers starting from the 60s till nowadays? What is studied in university by engineers in computer science and then successfully forgotten? What is at the heart of the compilers used daily by any software developer? Parsers! From a practical point of view using a small pill of theory, this session will bring lights on questions like: if there is so many parser-generators based on formal theory, then why javac, GCC and Clang are all hand-written? And how we, insiders of the world of parsing, do this at SonarSource for languages like Java, C/C++, C#, JavaScript, Python, COBOL?
This presentation is a part of the COP2272C college level course taught at the Florida Polytechnic University located in Lakeland Florida. The purpose of this course is to introduce students to the C++ language and the fundamentals of object orientated programming..
The course is one semester in length and meets for 2 hours twice a week. The Instructor is Dr. Jim Anderson.
The second lecture of expert system with python course.
Enjoy!
you can find the first lecture here:
https://www.slideshare.net/ahmadhussein45/expert-system-with-python-1
C++ CoreHard Autumn 2018. Concurrency and Parallelism in C++17 and C++20/23 -...corehard_by
What do threads, atomic variables, mutexes, and conditional variables have in common? They are the basic building blocks of any concurrent application in C++, which are even for the experienced C++ programmers a big challenge. This massively changed with C++17 and change even more with C++20/23. What did we get with C++17, what can we hope for with C++20/23? With C++17, most of the standard template library algorithms are available in sequential, parallel, and vectorised variants. With the upcoming standards, we can look forward to executors, transactional memory, significantly improved futures and coroutines. To make it short. These are just the highlights from the concurrent and parallel perspective. Thus there is the hope that in the future C++ abstractions such as executors, transactional memory, futures and coroutines are used and that threads, atomic variables, mutexes and condition variables are just implementation details.
Analysis of Haiku Operating System (BeOS Family) by PVS-Studio. Part 1PVS-Studio
Operating systems are among the largest and most complicated software projects, and that means they perfectly suit the purpose of demonstrating static code analysis' capabilities. After the successful analysis of Linux Kernel, I felt inspired to try analyzing other open-source operating systems as well.
This Presentation gives you all knowledge about #CPointers, #PointersInC.
The given slides are as follows:
1. Introduction of Pointers.
2. Systems to create a pointer in C.
3. Valid Pointer Examples in C.
4. Graphical representation of address assigning in c using pointer.
5. 1st Sample program of pointers in C.
6. Types of Pointers
7. NULL Pointer in C (Types of Pointer)
8. void Pointer in C (Types of Pointer)
9. Wild Pointer in C (Types of Pointer)
10. Changing value of variable using pointer
11. Update and Access value of variable using pointer in example.
12. Types of format specifies to print address in different format.
13. Advantages of Pointer in C.
14. Disadvantages of Pointer in C.
15. Pointers with Array using Programs. #pointerwitharray
16. Another Example of #pointerwitharray.
17. Relationship Between Arrays and Pointers.
18. Relationship Between Arrays and Pointers explanation with diagram.
19. Pointers and String. #PointersAndString
20. Function with Array Parameters using pointers.
21. Passing Pointers to Function or Pointer argument function. #PointerWithFunction
JLK Chapter 5 – Methods and ModularityDRAFT January 2015 Edition.docxvrickens
JLK Chapter 5 – Methods and ModularityDRAFT January 2015 Edition pg. 25
An Introduction to
Computer Science with Java, Python and C++
Community College of Philadelphia edition
Copyright 2017 by C.W. Herbert, all rights reserved.
Last edited October 8, 28, 2019 by C. W. Herbert
This document is a draft of a chapter from An Introduction to Computer Science with Java, Python and C++, written by Charles Herbert. It is available free of charge for students in Computer Science courses at Community College of Philadelphia during the Fall 2019 semester. It may not be reproduced or distributed for any other purposes without proper prior permission.
Please report any typos, other errors, or suggestions for improving the text to [email protected]
Chapter 5 – Python Functions and Modular Programming
Contents
Lesson 5.1User Created Functions in Python2
Python Function Parameters2
Value returning functions3
Example – Methods and Parameter Passing5
9
Lesson 5.2Top-Down Design and Modular Development10
Chapter Exercises13
User Created Functions in Python
So far we have only created software with one continuous Python script. We have used functions from other python modules, such as the square root method from the math class math.sqrt(n). Now we will begin to create our own functions of our own.
A Python function is a block of code that can be used to perform a specific task within a larger computer program. It can be called as needed from other Python software. Most programming languages have similar features, such as methods in Java or subroutines in system software.
The code for user-defined functions in Python is contained in a function definition. A Python function definition is a software unit with a header and a block of Python statements. The header starts with the keyword def followed by the name of the function, then a set parenthesis with any parameters for the function. A colon is used after the parentheses to indicate a block of code follows, just as with the if and while statements. The block of code to be included within the function is indented.
Here is an example of a Python function:
# firstFunction.py
# first demonstration of the use of a function for CSCI 111
# last edited 10/08/2o19 by C. Herbert
function
definition
def myFunction():
print ( "This line being printed by the function MyFunction.\n")
# end myFunction()
### main program ###
function used by the main part of the script
print("Beginning\n")
myFunction()
print("End\n")
# end main program
Functions can used for code that will be repeated within a program, or for modular development, in which long programs are broken into parts and the parts are developed independently. The parts can be developed as Python functions, then integrated to work together by being called from other software.
Python Function Parameters
Data can be passed to a Python function as a parameter of the function. Function parameters are variables listed in parentheses foll ...
Assignment 13/assg-13.cppAssignment 13/assg-13.cpp/**
* @author Jane Programmer
* @cwid 123 45 678
* @class COSC 2336, Spring 2019
* @ide Visual Studio Community 2017
* @date April 8, 2019
* @assg Assignment 13
*
* @description Assignment 13 Dictionaries and Hash table
* implementations.
*/
#include<cassert>
#include<iostream>
#include"KeyValuePair.hpp"
#include"Employee.hpp"
#include"HashDictionary.hpp"
usingnamespace std;
/** main
* The main entry point for this program. Execution of this program
* will begin with this main function.
*
* @param argc The command line argument count which is the number of
* command line arguments provided by user when they started
* the program.
* @param argv The command line arguments, an array of character
* arrays.
*
* @returns An int value indicating program exit status. Usually 0
* is returned to indicate normal exit and a non-zero value
* is returned to indicate an error condition.
*/
int main(int argc,char** argv)
{
// -----------------------------------------------------------------------
cout <<"----- testing Employee record and KeyValuePair class -----------"<< endl;
KeyValuePair<int, string> pair(42,"blue");
cout <<"test key: "<< pair.key()<< endl;
assert(pair.key()==42);
cout <<"test value: "<< pair.value()<< endl;
assert(pair.value()=="blue");
int id =3;
Employee e(id,"Derek Harter","1234 Main Street, Commerce TX",12345.67);
cout << e << endl;
assert(e.getId()==3);
assert(e.getName()=="Derek Harter");
cout << endl;
// -----------------------------------------------------------------------
cout <<"-------------- testing quadratic probing -----------------------"<< endl;
constint TABLE_SIZE =7;
HashDictionary<int,Employee> dict(TABLE_SIZE, EMPTY_EMPLOYEE_ID);
cout <<"Newly created hash dictionary should be empty, size: "<< dict.size()<< endl;
assert(dict.size()==0);
int probeIndex =0;
//cout << "probe index: " << probeIndex
// << " returned probe value: " << dict.probe(id, probeIndex)
// << endl;
//assert(dict.probe(id, probeIndex) == 2);
probeIndex =1;
//cout << "probe index: " << probeIndex
// << " returned probe value: " << dict.probe(id, probeIndex)
// << endl;
//assert(dict.probe(id, probeIndex) == 5);
probeIndex =5;
//cout << "probe index: " << probeIndex
// << " returned probe value: " << dict.probe(id, probeIndex)
// << endl;
//assert(dict.probe(id, probeIndex) == 37);
cout << endl;
// -----------------------------------------------------------------------
cout <<"-------------- testing mid-square hashing ----------------------"<< endl;
// the following asserts will only work for 32 bit ints, leave asserts
// commented out if you have 64 bit asserts
cout <<"Assuming 32 bit (4 byte) ints for these tests: "<<sizeof(int)<< endl;
assert(sizeof(int)==4);
//id = 3918;
//cout << "hash key: " << id
// << " returned hash value: " << dict.hash(id)
// << endl; ...
The French Revolution, which began in 1789, was a period of radical social and political upheaval in France. It marked the decline of absolute monarchies, the rise of secular and democratic republics, and the eventual rise of Napoleon Bonaparte. This revolutionary period is crucial in understanding the transition from feudalism to modernity in Europe.
For more information, visit-www.vavaclasses.com
Macroeconomics- Movie Location
This will be used as part of your Personal Professional Portfolio once graded.
Objective:
Prepare a presentation or a paper using research, basic comparative analysis, data organization and application of economic information. You will make an informed assessment of an economic climate outside of the United States to accomplish an entertainment industry objective.
Operation “Blue Star” is the only event in the history of Independent India where the state went into war with its own people. Even after about 40 years it is not clear if it was culmination of states anger over people of the region, a political game of power or start of dictatorial chapter in the democratic setup.
The people of Punjab felt alienated from main stream due to denial of their just demands during a long democratic struggle since independence. As it happen all over the word, it led to militant struggle with great loss of lives of military, police and civilian personnel. Killing of Indira Gandhi and massacre of innocent Sikhs in Delhi and other India cities was also associated with this movement.
Biological screening of herbal drugs: Introduction and Need for
Phyto-Pharmacological Screening, New Strategies for evaluating
Natural Products, In vitro evaluation techniques for Antioxidants, Antimicrobial and Anticancer drugs. In vivo evaluation techniques
for Anti-inflammatory, Antiulcer, Anticancer, Wound healing, Antidiabetic, Hepatoprotective, Cardio protective, Diuretics and
Antifertility, Toxicity studies as per OECD guidelines
A Strategic Approach: GenAI in EducationPeter Windle
Artificial Intelligence (AI) technologies such as Generative AI, Image Generators and Large Language Models have had a dramatic impact on teaching, learning and assessment over the past 18 months. The most immediate threat AI posed was to Academic Integrity with Higher Education Institutes (HEIs) focusing their efforts on combating the use of GenAI in assessment. Guidelines were developed for staff and students, policies put in place too. Innovative educators have forged paths in the use of Generative AI for teaching, learning and assessments leading to pockets of transformation springing up across HEIs, often with little or no top-down guidance, support or direction.
This Gasta posits a strategic approach to integrating AI into HEIs to prepare staff, students and the curriculum for an evolving world and workplace. We will highlight the advantages of working with these technologies beyond the realm of teaching, learning and assessment by considering prompt engineering skills, industry impact, curriculum changes, and the need for staff upskilling. In contrast, not engaging strategically with Generative AI poses risks, including falling behind peers, missed opportunities and failing to ensure our graduates remain employable. The rapid evolution of AI technologies necessitates a proactive and strategic approach if we are to remain relevant.
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdfTechSoup
In this webinar you will learn how your organization can access TechSoup's wide variety of product discount and donation programs. From hardware to software, we'll give you a tour of the tools available to help your nonprofit with productivity, collaboration, financial management, donor tracking, security, and more.
Introduction to AI for Nonprofits with Tapp NetworkTechSoup
Dive into the world of AI! Experts Jon Hill and Tareq Monaur will guide you through AI's role in enhancing nonprofit websites and basic marketing strategies, making it easy to understand and apply.
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...Levi Shapiro
Letter from the Congress of the United States regarding Anti-Semitism sent June 3rd to MIT President Sally Kornbluth, MIT Corp Chair, Mark Gorenberg
Dear Dr. Kornbluth and Mr. Gorenberg,
The US House of Representatives is deeply concerned by ongoing and pervasive acts of antisemitic
harassment and intimidation at the Massachusetts Institute of Technology (MIT). Failing to act decisively to ensure a safe learning environment for all students would be a grave dereliction of your responsibilities as President of MIT and Chair of the MIT Corporation.
This Congress will not stand idly by and allow an environment hostile to Jewish students to persist. The House believes that your institution is in violation of Title VI of the Civil Rights Act, and the inability or
unwillingness to rectify this violation through action requires accountability.
Postsecondary education is a unique opportunity for students to learn and have their ideas and beliefs challenged. However, universities receiving hundreds of millions of federal funds annually have denied
students that opportunity and have been hijacked to become venues for the promotion of terrorism, antisemitic harassment and intimidation, unlawful encampments, and in some cases, assaults and riots.
The House of Representatives will not countenance the use of federal funds to indoctrinate students into hateful, antisemitic, anti-American supporters of terrorism. Investigations into campus antisemitism by the Committee on Education and the Workforce and the Committee on Ways and Means have been expanded into a Congress-wide probe across all relevant jurisdictions to address this national crisis. The undersigned Committees will conduct oversight into the use of federal funds at MIT and its learning environment under authorities granted to each Committee.
• The Committee on Education and the Workforce has been investigating your institution since December 7, 2023. The Committee has broad jurisdiction over postsecondary education, including its compliance with Title VI of the Civil Rights Act, campus safety concerns over disruptions to the learning environment, and the awarding of federal student aid under the Higher Education Act.
• The Committee on Oversight and Accountability is investigating the sources of funding and other support flowing to groups espousing pro-Hamas propaganda and engaged in antisemitic harassment and intimidation of students. The Committee on Oversight and Accountability is the principal oversight committee of the US House of Representatives and has broad authority to investigate “any matter” at “any time” under House Rule X.
• The Committee on Ways and Means has been investigating several universities since November 15, 2023, when the Committee held a hearing entitled From Ivory Towers to Dark Corners: Investigating the Nexus Between Antisemitism, Tax-Exempt Universities, and Terror Financing. The Committee followed the hearing with letters to those institutions on January 10, 202
Embracing GenAI - A Strategic ImperativePeter Windle
Artificial Intelligence (AI) technologies such as Generative AI, Image Generators and Large Language Models have had a dramatic impact on teaching, learning and assessment over the past 18 months. The most immediate threat AI posed was to Academic Integrity with Higher Education Institutes (HEIs) focusing their efforts on combating the use of GenAI in assessment. Guidelines were developed for staff and students, policies put in place too. Innovative educators have forged paths in the use of Generative AI for teaching, learning and assessments leading to pockets of transformation springing up across HEIs, often with little or no top-down guidance, support or direction.
This Gasta posits a strategic approach to integrating AI into HEIs to prepare staff, students and the curriculum for an evolving world and workplace. We will highlight the advantages of working with these technologies beyond the realm of teaching, learning and assessment by considering prompt engineering skills, industry impact, curriculum changes, and the need for staff upskilling. In contrast, not engaging strategically with Generative AI poses risks, including falling behind peers, missed opportunities and failing to ensure our graduates remain employable. The rapid evolution of AI technologies necessitates a proactive and strategic approach if we are to remain relevant.
Model Attribute Check Company Auto PropertyCeline George
In Odoo, the multi-company feature allows you to manage multiple companies within a single Odoo database instance. Each company can have its own configurations while still sharing common resources such as products, customers, and suppliers.
2. Fazl-e-BasitFazl-e-Basit
ProgramProgram InstitutionInstitution
MS (Software Engineering )MS (Software Engineering )
(2 years)(2 years)
NUST (National UniversityNUST (National University
of Science &of Science &
Technology), RawalpindiTechnology), Rawalpindi
Computer SoftwareComputer Software
EngineeringEngineering
(4 years)(4 years)
Foundation UniversityFoundation University
Islamabad (FUI)Islamabad (FUI)
B. Sc (Computer Science)B. Sc (Computer Science) Peshawar UniversityPeshawar University
3. Working ExperienceWorking Experience
CurrentlyCurrently Assistant ProfessorAssistant Professor herehere –– CSCS
DepartmentDepartment
Worked as “Worked as “Project DirectorProject Director” LEADS Software” LEADS Software
House Peshawar (Registered with PSEB).House Peshawar (Registered with PSEB).
Worked as “Worked as “Lecturer/CoordinatorLecturer/Coordinator” Greenwich” Greenwich
University Peshawar.University Peshawar.
Worked as “Worked as “Software DeveloperSoftware Developer” Pi-Sigma (Prosol)” Pi-Sigma (Prosol)
Technologies, Software Technology Park,Technologies, Software Technology Park,
Islamabad.Islamabad.
4. Objective of the CourseObjective of the Course
Covering well-known data structures suchCovering well-known data structures such
as dynamic arrays, linked lists, stacks,as dynamic arrays, linked lists, stacks,
queues, trees and graphs etc.queues, trees and graphs etc.
To Prepare students for (and is aTo Prepare students for (and is a
prerequisite for) the more advancedprerequisite for) the more advanced
material students will encounter in latermaterial students will encounter in later
courses.courses.
Implementing data structures and classicalImplementing data structures and classical
computer science problems in C++.computer science problems in C++.
6. Material / ResourcesMaterial / Resources
Text BookText Book
Fundamentals of Data Structures in C++ byFundamentals of Data Structures in C++ by
horowitz, sahni and mehta.horowitz, sahni and mehta.
wwwwww
Any other good book on Data StructureAny other good book on Data Structure
8. Keys for success in the course…….Keys for success in the course…….
100 %100 % AttendanceAttendance
Solving AssignmentsSolving Assignments YourselvesYourselves
AttentiveAttentive in class sessionsin class sessions
AskingAsking questionsquestions && questionsquestions unless youunless you
are clear about your problem.are clear about your problem.
10. Every byte in the computer’s memory has anEvery byte in the computer’s memory has an
address.address. Addresses are numbers just as everyAddresses are numbers just as every
house in a locality has got an address.house in a locality has got an address.
Your program, when it is loaded into memory,Your program, when it is loaded into memory,
occupies certain range of these addresses. Thisoccupies certain range of these addresses. This
means that every variable and every function inmeans that every variable and every function in
your program starts with a particular addressyour program starts with a particular address
NOTE :NOTE : Pointer can only contain thePointer can only contain the ADDRESSADDRESS
of certain memory location.of certain memory location.
11. Normally a variable directly contains a specificNormally a variable directly contains a specific
value. Pointer, on the other hand, contains anvalue. Pointer, on the other hand, contains an
address of the variable that contains the specificaddress of the variable that contains the specific
value.value.
Pointers, like other variables must be declaredPointers, like other variables must be declared
before they are used. For e.g.before they are used. For e.g.
int *pttrr, temp;int *pttrr, temp;
Pointers should be initialized either when they arePointers should be initialized either when they are
declared or in an assignment statement. A pointerdeclared or in an assignment statement. A pointer
may be initialized tomay be initialized to 00,, NULLNULL or anor an addressaddress. A. A
pointer with the valuepointer with the value 00 oror NULLNULL points to nothing.points to nothing.
12. NULLNULL is a symbolic constant defined in theis a symbolic constant defined in the
header fileheader file <iostream.h>.<iostream.h>. Initializing a pointer toInitializing a pointer to
NULLNULL is equivalent to initializing a pointer tois equivalent to initializing a pointer to 00..
Initializing a pointer is necessary to prevent itInitializing a pointer is necessary to prevent it
pointing to unknown or un-initialized area ofpointing to unknown or un-initialized area of
memory.memory.
There are two pointer operators;There are two pointer operators;
thethe address ofaddress of operatoroperator &&
andand
indirection operatorindirection operator oror dereferencing operatordereferencing operator
i.e.i.e. **..
13. && is a unary operator that returns theis a unary operator that returns the address ofaddress of itsits
operand. For e.g.operand. For e.g.
int x = 5;int x = 5;
int *ptrr = NULL;int *ptrr = NULL;
ptrr = &x;ptrr = &x;
In aboveIn above ** showsshows ptrrptrr is pointer variable whose typeis pointer variable whose type
isis intint i.e. it can only contain thei.e. it can only contain the address ofaddress of anyany
integer variablesinteger variables in memory.in memory.
SimilarlySimilarly
14. cout<< *ptrr <<“n”;cout<< *ptrr <<“n”;
cout<< x <<“n”;cout<< x <<“n”;
Will produce the same resultWill produce the same result 55. Here. Here ** meansmeans
value ofvalue of the variable to whichthe variable to which ptrrptrr points to, whichpoints to, which
isis xx..
Note that the dereferenced pointer may also beNote that the dereferenced pointer may also be
used on the left side of an assignment statementused on the left side of an assignment statement
as follows.as follows.
*pttr = 9;*pttr = 9; oror
cin>>*ptrr;cin>>*ptrr;
Following program explains the concept ofFollowing program explains the concept of
pointerspointers
15. #include<iostream.h>#include<iostream.h>
void main( )void main( )
{{
int x = 5;int x = 5;
int *ptrr = NULL;int *ptrr = NULL;
ptrr = &x;ptrr = &x;
cout<< *ptrr <<“n”;cout<< *ptrr <<“n”;
cout<< x <<“n”;cout<< x <<“n”;
*pttr = 9;*pttr = 9;
cout<< &x <<“n”;cout<< &x <<“n”;
cout<< *&ptrr <<“n”;cout<< *&ptrr <<“n”;
// cancel effect of each other// cancel effect of each other ( &( & andand *)*)
cout<< &*ptrr <<“n”;cout<< &*ptrr <<“n”;
cout<< ptrr <<“n”;cout<< ptrr <<“n”;
cout<< *ptrr <<“n”;cout<< *ptrr <<“n”;
cout<< x <<“n”;cout<< x <<“n”;
}}
Output of ProgramOutput of Program
55
55
0x0064FDF40x0064FDF4
0x0064FDF40x0064FDF4
0x0064FDF40x0064FDF4
0x0064FDF40x0064FDF4
99
99
16. newnew andand deletedelete operatorsoperators
Variables created during execution ( run time ) ofVariables created during execution ( run time ) of
a program by means of special operation isa program by means of special operation is
known asknown as Dynamic DataDynamic Data. In C++ operation is. In C++ operation is
new.new.
The new operation has two formsThe new operation has two forms
newnew DataTypeDataType
newnew DataType [intExpression]DataType [intExpression]
First form is used for creating a single varaible ofFirst form is used for creating a single varaible of
type DataType ( e.g. int,…) attype DataType ( e.g. int,…) at run timerun time.. SecondSecond
form creates an array whose elements are ofform creates an array whose elements are of
type DataType ( e.g. char,…) attype DataType ( e.g. char,…) at run time.run time.
17. ExampleExample
intint **intptr;intptr;
charchar **namestr;namestr;
intptr =intptr = newnew int;int;
namestr =namestr = newnew char[8];char[8];
Variables created byVariables created by newnew are said to be on theare said to be on the
free storefree store oror heapheap, a region of memory set aside, a region of memory set aside
forfor Dynamic VariablesDynamic Variables..
The new operator obtains a chunk (portion) ofThe new operator obtains a chunk (portion) of
memory from thememory from the free storefree store..
18. AA Dynamic VariableDynamic Variable isis unnamedunnamed and cannotand cannot
bebe directly addresseddirectly addressed. It must be. It must be indirectlyindirectly
addressedaddressed through the pointer returned by thethrough the pointer returned by the
newnew operator.operator.
intint **intptr =intptr = newnew int;int;
charchar **namestr =namestr = newnew char[8];char[8];
*intptr = 357;*intptr = 357;
strcpy( namestr, “datastructure” );strcpy( namestr, “datastructure” );
19. Dynamic dataDynamic data can becan be destroyeddestroyed at any timeat any time
during theduring the executionexecution of a program when it is noof a program when it is no
longer needed. The built-in operatorlonger needed. The built-in operator deletedelete doesdoes
that and has two forms,that and has two forms, oneone for deleting singlefor deleting single
variable, thevariable, the otherother for deleting an array.for deleting an array.
deletedelete pointer;pointer;
deletedelete [ ] pointer;[ ] pointer;
21. Inaccessible object :Inaccessible object :
A dynamic variable on the free store withoutA dynamic variable on the free store without
any pointer pointing to it.any pointer pointing to it.
Dangling pointer :Dangling pointer :
A pointer that points to a variable that hasA pointer that points to a variable that has
been deallocated.been deallocated.
NOTE :NOTE : Leaving inaccessible objects on the freeLeaving inaccessible objects on the free
store should be considered a logic error.store should be considered a logic error.
25. void trial :: startin()void trial :: startin()
{{
cout<<"n Making use of "new" and "delete" is as follows.n";cout<<"n Making use of "new" and "delete" is as follows.n";
cout<<"n ---------------------------------------------------nn";cout<<"n ---------------------------------------------------nn";
temp1 = new node;temp1 = new node;
temp2 = new node;temp2 = new node;
cout<<"n Enter information about temp1.n";cout<<"n Enter information about temp1.n";
cin>>temp1->info;cin>>temp1->info;
cout<<"n Enter information about temp2.n";cout<<"n Enter information about temp2.n";
cin>>temp2->info;cin>>temp2->info;
temp3 = &obj1;temp3 = &obj1;
cout<<"n Enter information about temp3.n";cout<<"n Enter information about temp3.n";
cin>>temp3->info;cin>>temp3->info;
cout<<"n Showing information of temp1.n";cout<<"n Showing information of temp1.n";
cout<<temp1->info;cout<<temp1->info;
cout<<"n Showing information of temp2.n";cout<<"n Showing information of temp2.n";
cout<<temp2->info;cout<<temp2->info;
cout<<"n Showing information of temp3.n";cout<<"n Showing information of temp3.n";
cout<<temp3->info;cout<<temp3->info;
cout<<"n ---------------------------------------------------nn";cout<<"n ---------------------------------------------------nn";
26. cout<<" Now enter the length of character array.n";cout<<" Now enter the length of character array.n";
cin>>length;cin>>length;
p = new char[length]; // allocate 10 charsp = new char[length]; // allocate 10 chars
q = p;q = p;
cout<<" Now enter "<<length<<" characters to fill an array.n";cout<<" Now enter "<<length<<" characters to fill an array.n";
for( i=0;i<length; i++ )for( i=0;i<length; i++ )
{{
cin>>*p;cin>>*p;
p = p + 1;p = p + 1;
}}
p = q;p = q;
27. cout<<" nElements of array are as follows.n";cout<<" nElements of array are as follows.n";
for( i=0;i<length; i++ )for( i=0;i<length; i++ )
{{
cout<<*p<<", ";cout<<*p<<", ";
p = p + 1;p = p + 1;
}}
p = q;p = q;
}//--- END of startin( )---------------------------------------------------------------}//--- END of startin( )---------------------------------------------------------------