Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

ADA question: I am trying to make: the function Top (S : Stack) return Item_Type, which returns the top item on the stack or raises

ADA question:

I am trying to make: the function Top (S : Stack) return Item_Type, which returns the top item

on the stack or raises the Underflow exception, to the generic unbounded stack package.

Current Code:

--start of code

package body Unbound_Stack is type Cell is record Item : Item_Type; Next : Stack; end record; procedure Push (Item : in Item_Type; Onto : in out Stack) is begin Onto := new Cell'(Item => Item, Next => Onto); end Push; procedure Pop (Item : out Item_Type; From : in out Stack) is begin if Is_Empty(From) then raise Underflow; else Item := From.Item; From := From.Next; end if; end Pop; function Is_Empty (S : Stack) return Boolean is begin return S = null; end Is_Empty; --added function Top (S : Stack) return Item_Type is begin --Raise the underflow if Is_Empty(S) then raise Underflow; else --or return top item from the stack, call pop Pop (Item_Type, from => S); end if; return tem_Type; end Top; end Unbound_Stack; --end of code

current error:

image text in transcribed

Builder results (3 items) D unbound_stack.adb (3 items) invalid use of subtype mark in expression or call 35:15 35:34 actual for "From" must be a variable 37:14"tem_Type" is undefined Builder results (3 items) D unbound_stack.adb (3 items) invalid use of subtype mark in expression or call 35:15 35:34 actual for "From" must be a variable 37:14"tem_Type" is undefined

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Database Experts Guide To SQL

Authors: Frank Lusardi

1st Edition

0070390029, 978-0070390027

More Books

Students also viewed these Databases questions

Question

Define Administration?

Answered: 1 week ago

Question

Question Can a self-employed person adopt a profit sharing plan?

Answered: 1 week ago