Sep 1, 2012 at 1:31pm UTC
you cannot create an object like you did in line 15. you have to replace both "string" with actual strings, or make default names. Also you need to implement your constructor.
Edit:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
#include <iostream>
#include <string>
using namespace std;
class Film
{
public :
string name;
string type;
Film(string name, string type);
};
Film::Film(string name="" , string type="" ) {
this ->name=name;
this ->type=type;
}
int main()
{
Film nyFilm;
getline(cin, nyFilm.name);
}
}
Edit: Should work
Last edited on Sep 1, 2012 at 2:14pm UTC
Sep 1, 2012 at 1:38pm UTC
- defined your constructor
- learn how to pass to functions
just for reminder :)
Last edited on Sep 1, 2012 at 1:39pm UTC
Sep 1, 2012 at 2:03pm UTC
The compiler returns error on line
9, 12, 13, 14...
9|error: after previous specification in 'Film::Film(std::string, std::string)'|
12|error: default argument given for parameter 2 of 'Film::Film(std::string, std::string)'|
13|error: request for member 'name' in 'this', which is of non-class type 'Film* const'|
14|error: request for member 'type' in 'this', which is of non-class type 'Film* const'|
20|error: request for member 'name' in 'nyFilm', which is of non-class type 'Film()'|
Is there an #include
missing? It's a lot of errors and I can not figure it out....
Thanks anyway! =)
Sep 1, 2012 at 2:14pm UTC
The code above should work now, hope it helps.
Sep 1, 2012 at 2:21pm UTC
Works like a charm! Thank you very much!
I will probably be back with more problems when I get futher on with my archive.
Thank you!