Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7890915
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T06:28:51+00:00 2026-06-03T06:28:51+00:00

This post is a follow-up of a previous post: Ada: Understanding private types and

  • 0

This post is a follow-up of a previous post:

Ada: Understanding private types and understanding packaging

I am trying to create an object named Configuration, print it on the screen so that I can see its contents and also try to access the components of this created object. It is the last part that is giving me trouble. The codes are given next:

First the package specification Rectangular_Method.ads:

package Rectangular_Method is
type Rectangular is private;

function Construct(Horz, Vert : Long_Float) return Rectangular;

procedure Print(Configuration: in Rectangular);

procedure Vector_Basis_r (A : in Long_Float; D : out Rectangular);

function Get_Horz (R : Rectangular) return Long_Float;
function Get_Vert (R : Rectangular) return Long_Float;

private
type Rectangular is
    record
         Horz, Vert: Long_Float;
    end record;

end Rectangular_Method;

Next, the package body Rectangular_Method.adb:

with Ada.Text_IO, Ada.Long_Float_Text_IO;
with Ada.Numerics.Long_Elementary_Functions;
use  Ada.Numerics.Long_Elementary_Functions;

package body Rectangular_Method is

function Construct(Horz, Vert : Long_Float) return Rectangular is
begin
  return(Horz, Vert);
end Construct;

procedure Print(Configuration: in Rectangular) is
use Ada.Text_IO, Ada.Long_Float_Text_IO;
  begin
Put("(");
Put(Configuration.Horz, Fore => 2, Aft => 2, Exp => 0); Put(", ");
Put(Configuration.Vert, Fore => 2, Aft => 2, Exp => 0);
Put_Line(")");
  end Print;

procedure Vector_Basis_r (A : in Long_Float; D : out Rectangular) is
begin
  D.Horz := Cos (A, Cycle => 360.0);
  D.Vert := Sin (A, Cycle => 360.0);
end Vector_Basis_R;

function Get_Horz (R : Rectangular) return Long_Float is
begin
  return R.Horz;
end Get_Horz;

function Get_Vert (R : Rectangular) return Long_Float is
begin
  return R.Vert;
end Get_Vert;
end Rectangular_Method;

And finally the test file test_rectangular_form.adb:

with Ada.Long_Float_Text_IO;
with Ada.Text_IO; use Ada.Text_IO;

with Rectangular_Form;
use type Rectangular_Form.Rectangular;
procedure Test_Rectangular_Form is

Theta                                 : Long_Float;
Basis_r                               : Rectangular_Form.Rectangular;

Configuration: Rectangular_Form.Rectangular;

begin
   Ada.Text_IO.Put("Enter the angle ");
   Ada.Long_Float_Text_IO.Get (Item => theta);

   --Vector basis
   Rectangular_Form.Vector_Basis_R (A => Theta, D => Basis_R);

   Configuration := Rectangular_Form.Construct(Rectangular_Form.Get_Horz (Basis_R),Rectangular_Form.Get_Vert (Basis_R));
   Ada.Text_IO.New_Line;
   Rectangular_Form.Print(Configuration);

end Test_Rectangular_Form;

Now the question (based on test_rectangular_form.adb):

I have created an object Configuration as shown above holding the horizontal and vertical components of Basis_R. If I want to access say the horizontal component of Configuration, the following doesn’t work:

aa := Rectangular_Form.Configuration.Rectangular.Horz;

(after defining aa to be of type Long_Float)

I have tried various expressions to access the components of the object Configuration but in vain.

Any help would be most appreciated.

Thanks…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T06:28:53+00:00Added an answer on June 3, 2026 at 6:28 am

    The purpose of your Get_Horz and Get_Vert functions is to retrieve the components of your Rectangular object:

    aa := Rectangular_Form.Get_Horz(Configuration);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This post is the follow-up of my previous post (Create and retrieve object list
This is a follow-up question of my previous post . I am trying to
This post if a follow-up question to mt previous post: Android RESTful Web application
This is a follow-up question related to my previous post . Below is a
This is a follow up of this [post] Ada: Adding an exception in a
I'm trying to follow the instructions laid out in this post , but I'm
This is a follow up question to a previous post on saving recent searches
This is a follow up question to my previous question . I am trying
This is a follow-on to a previous post . I am now looking at
This is a follow-up question to my previous post: Python/Scipy Interpolation (map_coordinates) Let's say

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.