-
nested class question
Hello
Suppose I have:
Code:
class someclass {
public:
typedef std::vector<std::string> str_vector;
class nestedclass {
public:
nestedclass(str_vector &sv) : str_vector_(sv) { }
private:
str_vector &str_vector_;
};
private:
str_vector str_vector_;
};
Is thats the right way of using str_vector data type inside nested class? Or should I use someclass::str_vector instead?
-
That works; since you're inside the class itself you don't need the class's qualifiers. It's like going
Code:
namespace outer {
namespace inner_one {
typedef int type;
}
namespace inner_two {
/* You don't need outer::inner_one::type, just inner_one::type */
inner_one::type variable;
}
}
Did you try compiling your code?
-
Yeah. Works okay..
I posted because I was unsure because I got compiling error because of some other reason..
Thanks!