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

  • Home
  • SEARCH
  • 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 8510391
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T03:41:28+00:00 2026-06-11T03:41:28+00:00

I have a need to convert/upgrade my data structure struct to a class and

  • 0

I have a need to convert/upgrade my data structure struct to a class and have a question:
Can I statically initiate my class like the struct? If so, any guidance of how to do it would be highly appreciate.
Below is the definition of my struct:

typedef struct t
{
   struct t *next;
   int otherfield;
} T

T r1[]={{0,1},{0,2}};
T s1[]={{r1,3},{0,4}};

My converted class looks like

class T
{
  class T next;
  int otherfield;
}
List<T> r1;
List<T> s1;

How do I statically initiate r1, s1. Standard initialization thru a constructor may not work as I have hundred of these struct and they were all initialized statically.

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-11T03:41:30+00:00Added an answer on June 11, 2026 at 3:41 am

    Can’t you just do the following?

    class T
    {
        public T next;
        public int otherfield;
        public T( T next, int otherfield )
        {
            this.next = next;
            this.otherfield = otherfield
        }
    }
    
    T[] r1 = new T[]{ new T( null, 1 ), new T( null, 2 ) };
    T[] s1 = new T[]{ new T( r1[0], 3 ), new T( null, 4 ) };
    

    Edit: if you want to do it with a List then you could do the following:

    List< T > r1 = new List< T >( new T[]{ new T( null, 1 ), new T( null, 2 ) } );
    List< T > s1 = new List< T >( new T[]{ new T( r1[0], 3 ), new T( null, 4 ) } );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a string.i need to convert it to Voice. can any one help
I have problem i need to convert from my Array structure to std::vector<int> ...
I have a situation in which I need to convert a text data into
I have the following int 7122960 I need to convert it to 71229.60 Any
I have some .class files that I need to convert to .java so I
i have C# Winform program and i need to convert it to Webform. can
Usually when I have need to convert currency string (like 1200,55 zł or $1,249)
I have a byte array and I need to convert this to a image.
I have a string x that I need to convert into a hex format:
I have an situation where i need to convert Doc file into PDF file.

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.