Problem when using array of qstring or vectors of qstring



  • Hey guys , I had this problem and I couldn't fix it here's the code:

    @
    QString *array_of_Grades; // in header

    array_of_Grades=new QString[9] {"A+,A,B+,B,C+,C,D+,D,F"}; // in imp

    @

    it gives me these errors!

    @
    error: C2143: syntax error : missing ';' before '{'
    error: C2143: syntax error : missing ';' before '}'

    @



  • QStringList array_of_Grades;
    array_of_Grades << "A+" << "A" << "B+" << "B" << ...


  • Moderators

    I agree with wlinaz. It's always far best (cleaner, safer, etc.) to use the provided container classes rather than relying on manual C-style arrays or pointer handling.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.