You can, but here you treat movie as a member while it is really a typename. It should be
1 2 3 4 5 6 7 8 9 10 11
class Test
{
public:
Test(struct movie mv) : my_movie(mv) {}//I don't know if you need that "struct" here.
private:
struct movie
{
int year;
string name;
} my_movie;
};
Nesting a class (or struct) inside another class really only changes it's name. It's sort of like putting a class inside a namespace. Think of the inner class as a static member of the outer class, that is, each instance of the Outer does not have it's own definition for Inner (or Inner's members.)
1 2 3 4 5 6 7 8 9 10
namespace Space
{
class Outer //It's full name is Space::Outer
{
class Inner //It's full name is Space::Outer::Inner
{
...
};
};
}
Whoops, wasn't really looking at what he had in the struct in terms of data type. Yea, that (those) needs to be changed to char *staffNum;, or constchar *staffNum; in which case you would need to set it (them) via an initializer list.