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 7928159
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T19:39:55+00:00 2026-06-03T19:39:55+00:00

What is the difference between a pointer and an instance in struct. How do

  • 0

What is the difference between a pointer and an instance in struct. How do you instantiate an instance and pointer in struct? How do you connect a pointer?

Can anyone explain with an example?

  • 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-03T19:39:57+00:00Added an answer on June 3, 2026 at 7:39 pm

    A unit instance declares an instance of a unit. A unit reference (also called a unit pointer) points to a unit that already exists in the unit hierarchy, or has a value of NULL when it does not point to anything.

    Units are static items that can only be created during pre-run generation and can never be destroyed (dereferenced and then garbage collected). A unit can only be instantiated within another unit. So every e program has a tree of unit instances with sys (the only predefined unit) at the root. This is in contrast to structs, which can be dynamically created at any time during the test phase.

    unit simple_u {};
    
    struct example_s {
      generated_ref  : simple_u;
      generated_inst : simple_u is instance; // Illegal: Instance cannot be in struct
    };
    

    Since unit instances can only be created during pre-run generation, they cannot be declared with the do-not-generate operator (!):

    generated_inst : simple_u is instance;
    !nongen_inst   : simple_u is instance; // Illegal: Instances must be generated.
    

    A unit reference can either be generated or not. If it is generated, then it must have a constraint that either points it at a separately declared unit instance or NULL:

    !nongen_ref    : simple_u;
    generated_ref  : simple_u; // Requires a generation constraint (like below)
    keep soft generated_ref == NULL;
    keep      generated_ref == generated_inst;
    

    It is illegal to use the gen action on a unit instance. A unit reference can be generated at any time (on-the-fly), but it must have pre-existing constraint or have one specified with a keeping block:

    gen generated_inst; // Illegal to explicitly generate an instance
    gen generated_ref;
    gen nongen_ref keeping {it == generated_inst};
    

    It is legal to assign to a unit reference in procedural code, but a unit instance cannot be assigned to:

    generated_ref  = NULL;
    generated_inst = NULL; // Illegal to assign to an instance
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I can't seem to understand the difference between the following to pointer notations, can
Possible Duplicate: Difference between pointer variable and reference variable in C++ When should I
Possible Duplicate: Difference between pointer variable and reference variable in C++ I am reading
What is the difference between a constant pointer and a reference? Constant pointer as
What is the difference between passing-by-reference and using the C pointer notation? void some_function(some_type&
In C++, what is the difference between the following examples? Re-throw pointer : catch
What I don't understand is what is the difference between using a pointer to
See http://jsfiddle.net/FDhQF/1/ for a trivial example. What's the difference between something being undefined and
what is the difference between deleting a pointer, setting it to null, and freeing
I'm trying to benchmark the difference between a function pointer call and a virtual

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.