Book2.cpp:187: error: expected primary-expression before '{' token

I have extracted this one line in my program that gives the error above
I do not know what is the meaning of this error:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
  #include <string>
#include <iostream>
#include <iomanip>
  
using namespace std;
  
class bookType
{
public:
    bookType();
    void setTitle (string);
    string getTitle ();
    bool compareTitle(string);
    void setAuthor(string="");
    void showAuthors();
    void updateAuthor(string="");
    string *getAuthors ();
    void setCopies (int);
    void showCopies ();
    void updateCopies(int);
    int getCopies();
    void setPublisher(string);
    void showPublisher();
    void updatePublisher(string);
    string getPublisher();
    void setISBN(string);
    void showISBN();
    void updateISBN(string);
    string getISBN();
    bool compareISBN(string);
    void setPrice(double);
    void showPrice();
    void updatePrice(double);
    double getPrice();
  
private:
    string title;
    string authors [4];
    string publisher;
    string ISBN;
    double price;
    int copies;
    int authorsNo;
};
  
#include <iostream>
//#include "bookType.h"
using namespace std;
  
bookType::bookType()
{
    title="";
    for (int i=0; i<4; i++)
        authors[i];
    publisher="";
    ISBN="";
    price=0;
    copies=0;
    authorsNo=0;
}
 
void bookType::setTitle(string myTitle)
{
    title=myTitle;
}
 
string bookType::getTitle()
{
    return title;
}
bool bookType::compareTitle (string otherTitle)
{
    return (title.compare(otherTitle)==0);
}
 
void bookType::setAuthor(string myAuthor)
{
    authorsNo=authorsNo % 4;
 
    if(myAuthor.compare("")==0)
        return;
    else
    {
        authors [authorsNo]=myAuthor;
        authorsNo++;
    }
}
 
void bookType::showAuthors()
{
    for (int i=0; i< authorsNo; i++)
        cout<<authors [i]<< ", ";
    cout<<"\r\r";
}
 
void bookType::updateAuthor(string myAuthor)
{
    setAuthor(myAuthor);
}
 
string *bookType::getAuthors()
{
    return authors;
}
 
void bookType::setCopies(int myCopies)
{
    copies=myCopies;
}
 
void bookType::showCopies()
{
    cout<<"There are" <<copies<< "copies of this book.";
}
 
void bookType::updateCopies(int myCopies)
{
    copies=myCopies;
}
 
int bookType::getCopies()
{
    return copies;
}
 
void bookType::setPublisher(string myPublisher)
{
    publisher=myPublisher;
}
 
void bookType:: showPublisher()
{
    cout<<publisher;
}
 
void bookType::updatePublisher(string myPublisher)
{
    publisher=myPublisher;
}
 
string bookType::getPublisher ()
{
    return publisher;
}
 
void bookType::setISBN(string myISBN)
{
    ISBN=myISBN;
}
 
void bookType:: showISBN()
{
    cout<< ISBN;
}
 
void bookType::updateISBN(string myISBN)
{
    ISBN=myISBN;
}
 
string bookType::getISBN()
{
    return ISBN;
}
 
bool bookType::compareISBN(string myISBN)
{
    return(myISBN.compare(ISBN) == 0);
}
 
void bookType::showPrice()
{
    cout<< "The price of this book is  "<<price;
}
 
void bookType::updatePrice( double myPrice)
{
    price=myPrice;
}
 
double bookType::getPrice()
{
    return price;
}

int main() {
    bookType Book2("Sweet",{"lil","lool","lal","ln"},"ssss",29288308.47,8,3,2);
    return 0;
}
For that line to work you need to use a compiler that at least supports the C++11 standard. If you have such a compiler you will get another error message telling you that there is no bookType constructor that match the arguments that you tried to pass.
Peter87 wrote:
If you have such a compiler you will get another error message telling you that there is no bookType constructor that match the arguments that you tried to pass.

Interestingly enough, there are several examples of such constructors in this thread:
http://www.cplusplus.com/forum/beginner/225027/
I think I am using very old compilers.
I will google the new ones.

Thank you all
Topic archived. No new replies allowed.