I've got a bit of code that looks something like this:
The highlighted bit is where I'm stuck. I get the error:Code:template <typename T> class A { private: class B { public: B() { count = 0 } T data; private: unsigned int count; friend class A; }; public: A(); B* do_stuff(T some_data); }; template <typename T> A<T>::B* A<T>::do_stuff(T some_data) { B* temp = new B; temp->data = some_data; ++(temp->count); return temp; }
I think I'm on the right track, but now I'm totally lost. Any advice?'A<T>::B' : dependent name is not a type
On a related note, in main() I'm looking to create a vector of B*. Is there any way of me doing that without having to declare the whole mess public? I want to do this:
However, I don't want to whole world access to anything inside of B. What am I forgetting to do?Code:int main() { A<int> MyClass; vector<A<int>::B*> my_vector; for(int i = 0; i < 10; ++i) { my_vector.push_back(MyClass.do_stuff(i)); } return 0; }



LinkBack URL
About LinkBacks


