• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Is this the right way in C++?

LumbergTech

Diamond Member
In java I would have done:

Code:
fillArray(myArray);

void fillArray(objArray myArray)
{
     for(int x = 0 ; x < 5; x++)
          myArray[x] = new Parameter("Description", "Name", "Value");
}

Can I do the same thing in C++?

Code:
QList<Parameter> parameters;

fillList(parameters);

void fillList(QList<Parameter>& myList)
{
     for(int x = 0; x < 5; x++)
          myList.append(new Parameter("Description", "Name", "Value");
}

IF this is not the correct way to handle things, what can I do differently?
 
Last edited:
using new in C++ returns the pointer to the object or data structure or w/e. you would have to declare the list as QList<Parameter *> if you want to use new. that or don't use new.
 
Back
Top