Error with strings in constructor

Hi, a little help please!

In addition to the constructors below there are also default constructors that take nothing and interactively get the values.

Here is the code:
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
Class Entry {

//...

Entry (int number, string newname) {
id = number;
name = newname;
}

//...
};

class Book {

//...

Book (int number, string newname, string newauthor, string newpublisher, string newedition, string newyear) : Entry(number, newname) {
author = newauthor;
publisher = newpublisher;
edition = newedition;
year = newyear;
}
//...
};

void main(){
Book b (1, 'test', 'test', 'test', 'test', 'test');
}


I get compile error C2664:cannot convert parameter 2 from 'int' to 'std::string'

but parameter 2 is a string??!!

Any ideas?

Thanks
Hi
In the Book Constructor The parameters are string where as while creating the instance accidentally U r passing char.

Instead of
Book b (1, 'test', 'test', 'test', 'test', 'test');
use
Book b (1, "test", "test", "test", "test", "test");



Topic archived. No new replies allowed.