Click here to Skip to main content
15,883,825 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
What does it mean to have the { } after the vector?
QVector<album*> AlbumDao::albums() const
{
QSqlQuery query("SELECT * FROM albums", mDatabase);
query.exec();
QVector<album*> list;
while(query.next()) {
Album* a->setId(query.value("id").toInt()); album = new Album();
album->setName(query.value("name").toString());
list.append(album);
}

What I have tried:

What does it mean to have the { } after the vector?
C++
QVector AlbumDao::albums() const
{
    QSqlQuery query("SELECT * FROM albums", mDatabase);
    query.exec();
    QVector list;
    while(query.next())
    {
        Album* a->setId(query.value("id").toInt());
        album = new Album();
        album->setName(query.value("name").toString());
        list.append(album);
    }
Posted
Updated 15-Nov-20 10:23am
v2
Comments
Richard MacCutchan 16-Nov-20 4:32am    
You need to learn C++ first, these questions are all covered in the basics of the language. And you will not learn it by posting questions here.

1 solution

First : you should learn how to add the code tags to your posts so one can see the code displayed properly.

Your question is unclear. Curly braces are used to delineate groups of code such as the extents of a function or a method, the boundaries of a while or for loop, the extents of conditional statements. Following the while statement there is a left curly brace, some lines of code, and a right brace. The code within that pair of braces will execute continuously while the expression in the while statement evaluates to true.

Braces are fundamental to the C++ language. I recommend you take a look at a tutorial: C++ Language Tutorials[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900