Hi,

I'm still with my vector and my Book class.
I have a strange behavior during construction of my class.
I my class constructor as 5 parameters it works, if it has 6 parameter,
VC.NET returns me an error :

error C2059: syntax error : ')'

here is code :

class Book
{
public:
std::string Category;
std::string SubCategory;
std::string Title;
std::string Author;
int Pages;
int Year;
std::string Publisher;
std::string Format;
std::string Description;
std::string Language;
std::string Image;
std::string Information;

// constructor
Book(std::string Arg_Category, std::string Arg_SubCategory, std::string
Arg_Title, std::string Arg_Author, int Arg_Pages, int Arg_Year,
std:string Arg_Publisher) : Category(Arg_Category),
SubCategory(Arg_SubCategory), Title(Arg_Title), Author(Arg_Author),
Pages(Arg_Pages), Year(Arg_Year), Publisher(Arg_Publisher)
{
}

};

this work when i use :

std::vector<Book> Books;
Books.push_back(Book("Category_1", "SubCategory_1",
"Title_1","Author_1", 588, 2004, "Publisher_1"));


but if in my class i have as constrcutor:

Book(std::string Arg_Category, std::string Arg_SubCategory, std::string
Arg_Title, std::string Arg_Author, int Arg_Pages, int Arg_Year,
std:string Arg_Publisher, std::string Arg_Format)
: Category(Arg_Category), SubCategory(Arg_SubCategory),
Title(Arg_Title), Author(Arg_Author), Pages(Arg_Pages), Year(Arg_Year),
Publisher(Arg_Publisher),Format(Arg_Format)
{
}

and i initialize it as such :
std::vector<Book> Books;
Books.push_back(Book("Category_1", "SubCategory_1",
"Title_1","Author_1", 588, 2004, "Publisher_1", "Format_1"));

i get error written above :(

so, Is there any limitation for the number of parameters in constructor ?
if yes (and i've never seen it), how can i initialize more parameters ?

thx,
Maileen

Re: Class constructor limited in parameter ? by Chen

Chen
Sat Jun 19 09:19:03 CDT 2004

std:string Arg_Publisher

Erh... you had the fault in both the "correct" one and the "errornous"
one... :-)

And, well, it works for me after fixing that... Btw, you can use "using
namespace std;" to skip all those ugly "std::". ;-)

// Chen

"Maileen" <nospan@email.com> skrev i meddelandet
news:uHOXyleVEHA.4064@TK2MSFTNGP11.phx.gbl...
> Hi,
>
> I'm still with my vector and my Book class.
> I have a strange behavior during construction of my class.
> I my class constructor as 5 parameters it works, if it has 6 parameter,
> VC.NET returns me an error :
>
> error C2059: syntax error : ')'
>
> here is code :
>
> class Book
> {
> public:
> std::string Category;
> std::string SubCategory;
> std::string Title;
> std::string Author;
> int Pages;
> int Year;
> std::string Publisher;
> std::string Format;
> std::string Description;
> std::string Language;
> std::string Image;
> std::string Information;
>
> // constructor
> Book(std::string Arg_Category, std::string Arg_SubCategory, std::string
> Arg_Title, std::string Arg_Author, int Arg_Pages, int Arg_Year,
> std:string Arg_Publisher) : Category(Arg_Category),
> SubCategory(Arg_SubCategory), Title(Arg_Title), Author(Arg_Author),
> Pages(Arg_Pages), Year(Arg_Year), Publisher(Arg_Publisher)
> {
> }
>
> };
>
> this work when i use :
>
> std::vector<Book> Books;
> Books.push_back(Book("Category_1", "SubCategory_1",
> "Title_1","Author_1", 588, 2004, "Publisher_1"));
>
>
> but if in my class i have as constrcutor:
>
> Book(std::string Arg_Category, std::string Arg_SubCategory, std::string
> Arg_Title, std::string Arg_Author, int Arg_Pages, int Arg_Year,
> std:string Arg_Publisher, std::string Arg_Format)
> : Category(Arg_Category), SubCategory(Arg_SubCategory),
> Title(Arg_Title), Author(Arg_Author), Pages(Arg_Pages), Year(Arg_Year),
> Publisher(Arg_Publisher),Format(Arg_Format)
> {
> }
>
> and i initialize it as such :
> std::vector<Book> Books;
> Books.push_back(Book("Category_1", "SubCategory_1",
> "Title_1","Author_1", 588, 2004, "Publisher_1", "Format_1"));
>
> i get error written above :(
>
> so, Is there any limitation for the number of parameters in constructor ?
> if yes (and i've never seen it), how can i initialize more parameters ?
>
> thx,
> Maileen
>



Re: Class constructor limited in parameter ? by Maileen

Maileen
Sat Jun 19 10:31:34 CDT 2004

Sorry to tell you that Chen, but i don't see any error :(
so i think my eyes are destroyed buy searching this error so long :(


Chen wrote:

> std:string Arg_Publisher
>
> Erh... you had the fault in both the "correct" one and the "errornous"
> one... :-)
>
> And, well, it works for me after fixing that... Btw, you can use "using
> namespace std;" to skip all those ugly "std::". ;-)
>
> // Chen
>
> "Maileen" <nospan@email.com> skrev i meddelandet
> news:uHOXyleVEHA.4064@TK2MSFTNGP11.phx.gbl...
>
>>Hi,
>>
>>I'm still with my vector and my Book class.
>>I have a strange behavior during construction of my class.
>>I my class constructor as 5 parameters it works, if it has 6 parameter,
>>VC.NET returns me an error :
>>
>>error C2059: syntax error : ')'
>>
>>here is code :
>>
>>class Book
>>{
>> public:
>>std::string Category;
>>std::string SubCategory;
>>std::string Title;
>>std::string Author;
>>int Pages;
>>int Year;
>>std::string Publisher;
>>std::string Format;
>>std::string Description;
>>std::string Language;
>>std::string Image;
>>std::string Information;
>>
>>// constructor
>>Book(std::string Arg_Category, std::string Arg_SubCategory, std::string
>>Arg_Title, std::string Arg_Author, int Arg_Pages, int Arg_Year,
>>std:string Arg_Publisher) : Category(Arg_Category),
>>SubCategory(Arg_SubCategory), Title(Arg_Title), Author(Arg_Author),
>>Pages(Arg_Pages), Year(Arg_Year), Publisher(Arg_Publisher)
>>{
>>}
>>
>>};
>>
>>this work when i use :
>>
>>std::vector<Book> Books;
>>Books.push_back(Book("Category_1", "SubCategory_1",
>>"Title_1","Author_1", 588, 2004, "Publisher_1"));
>>
>>
>>but if in my class i have as constrcutor:
>>
>>Book(std::string Arg_Category, std::string Arg_SubCategory, std::string
>>Arg_Title, std::string Arg_Author, int Arg_Pages, int Arg_Year,
>>std:string Arg_Publisher, std::string Arg_Format)
>>: Category(Arg_Category), SubCategory(Arg_SubCategory),
>>Title(Arg_Title), Author(Arg_Author), Pages(Arg_Pages), Year(Arg_Year),
>>Publisher(Arg_Publisher),Format(Arg_Format)
>>{
>>}
>>
>>and i initialize it as such :
>>std::vector<Book> Books;
>>Books.push_back(Book("Category_1", "SubCategory_1",
>>"Title_1","Author_1", 588, 2004, "Publisher_1", "Format_1"));
>>
>>i get error written above :(
>>
>>so, Is there any limitation for the number of parameters in constructor ?
>>if yes (and i've never seen it), how can i initialize more parameters ?
>>
>>thx,
>>Maileen
>>
>
>
>


Re: Class constructor limited in parameter ? by theoneandonly

theoneandonly
Sun Jun 20 06:40:11 CDT 2004

Hi Maileen

There is a small error in your code. In your second constructor you
write 'std:string Arg_Publisher'. If you write 'std::string
Arg_Publisher' it sould work ;)

MC


Maileen <nospan@email.com> wrote in message news:<eww4BKhVEHA.1472@TK2MSFTNGP09.phx.gbl>...
> Sorry to tell you that Chen, but i don't see any error :(
> so i think my eyes are destroyed buy searching this error so long :(
>
>
> Chen wrote:
>
> > std:string Arg_Publisher
> >
> > Erh... you had the fault in both the "correct" one and the "errornous"
> > one... :-)
> >
> > And, well, it works for me after fixing that... Btw, you can use "using
> > namespace std;" to skip all those ugly "std::". ;-)
> >
> > // Chen
> >
> > "Maileen" <nospan@email.com> skrev i meddelandet
> > news:uHOXyleVEHA.4064@TK2MSFTNGP11.phx.gbl...
> >
> >>Hi,
> >>
> >>I'm still with my vector and my Book class.
> >>I have a strange behavior during construction of my class.
> >>I my class constructor as 5 parameters it works, if it has 6 parameter,
> >>VC.NET returns me an error :
> >>
> >>error C2059: syntax error : ')'
> >>
> >>here is code :
> >>
> >>class Book
> >>{
> >> public:
> >>std::string Category;
> >>std::string SubCategory;
> >>std::string Title;
> >>std::string Author;
> >>int Pages;
> >>int Year;
> >>std::string Publisher;
> >>std::string Format;
> >>std::string Description;
> >>std::string Language;
> >>std::string Image;
> >>std::string Information;
> >>
> >>// constructor
> >>Book(std::string Arg_Category, std::string Arg_SubCategory, std::string
> >>Arg_Title, std::string Arg_Author, int Arg_Pages, int Arg_Year,
> >>std:string Arg_Publisher) : Category(Arg_Category),
> >>SubCategory(Arg_SubCategory), Title(Arg_Title), Author(Arg_Author),
> >>Pages(Arg_Pages), Year(Arg_Year), Publisher(Arg_Publisher)
> >>{
> >>}
>
> >>};
> >>
> >>this work when i use :
> >>
> >>std::vector<Book> Books;
> >>Books.push_back(Book("Category_1", "SubCategory_1",
> >>"Title_1","Author_1", 588, 2004, "Publisher_1"));
> >>
> >>
> >>but if in my class i have as constrcutor:
> >>
> >>Book(std::string Arg_Category, std::string Arg_SubCategory, std::string
> >>Arg_Title, std::string Arg_Author, int Arg_Pages, int Arg_Year,
> >>std:string Arg_Publisher, std::string Arg_Format)
> >>: Category(Arg_Category), SubCategory(Arg_SubCategory),
> >>Title(Arg_Title), Author(Arg_Author), Pages(Arg_Pages), Year(Arg_Year),
> >>Publisher(Arg_Publisher),Format(Arg_Format)
> >>{
> >>}
> >>
> >>and i initialize it as such :
> >>std::vector<Book> Books;
> >>Books.push_back(Book("Category_1", "SubCategory_1",
> >>"Title_1","Author_1", 588, 2004, "Publisher_1", "Format_1"));
> >>
> >>i get error written above :(
> >>
> >>so, Is there any limitation for the number of parameters in constructor ?
> >>if yes (and i've never seen it), how can i initialize more parameters ?
> >>
> >>thx,
> >>Maileen
> >>
> >
> >
> >