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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T08:17:50+00:00 2026-05-24T08:17:50+00:00

Hello stackoverflow fellow members? Struct Declaration in class A struct PointSprite { GLfloat x;

  • 0

Hello stackoverflow fellow members?

Struct Declaration in class A

struct PointSprite 
{
    GLfloat x;
    GLfloat y;
    GLfloat size;
    Color4f color;
} ParticleSystems[MAXIMUM_PARTICLES_ON_SCREEN];
// I generally put some stuffs in ParticleSystem array. 
// for ex) struct PointSprite *ps = &ParticleSystems[index];
// and it works well on the class A, but I want to get class B to access this array.

My question is, how am I suppose be return the array of ‘ParticlelSystems‘ array so that other class can access to it? I have tried below code to return the pointer, but compiler gives me a warning.

- (struct ParticleSystems *) commitParticles
{
    struct ParticleSystems *ptr = &ParticleSystems; // it said, assigning incompatible pointer type
    
    return ptr;
}

Or should I need to allocate the ‘ParticleSystems‘ array? Please help ! 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-05-24T08:17:51+00:00Added an answer on May 24, 2026 at 8:17 am

    If you are creating the array inside the function then you should dynamically allocate it using new and then return a pointer to it.

    You cannot return arrays from a function, you will have to return a pointer to it.

    Sample Code:

    ParticleSystems* doSomethingInteresting()
    {
        ParticleSystems *ptr = new ParticleSystems[MAXIMUM_PARTICLES_ON_SCREEN];
    
        //do the processing
    
        return ptr;
    
    }
    

    The caller takes the ownership of the returned dynamically allocated array and needs to deallocate it to avoid memory leaks:

    delete []ptr;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello fellow stackoverflow family members? I know it is un-efficient to create one extra
Hello fellow stackoverflow members! I'm very new to the C# language transfer from Java,
Hello fellow StackOverflow users (or Stackoverflowers ?): I'm learning-by-coding WPF. I read several articles/saw
Hello helpful stackoverflow members, I'm trying to accomplish what seems to be a simple
Hello fellow stackoverflow-ers, I built an ajax image gallery and used asual' jquery address
Hello fellow Stackoverflow users, I have a page which does a AJAX request to
Hello stackoverflow community ! I am trying to figure out how to architect my
Hello StackOverflow'ers, I have a (flex) app that, on the click of a button,
Hello StackOverflow community, Using Google App Engine, I wrote a keyToSha256() method within a
Suppose I have this code: String encoding = UTF-16; String text = [Hello StackOverflow];

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.