I am trying to have a struct
declared in my class and then return a pointer
to that struct
using a member function in that class, but it does not work.
Here is my code:
someClass.h:
class someClass
{
public:
someClass();
sword* returnSword();
struct sword
{
int str;
char name;
};
sword* m_sword;
};
someClass.cpp:
#include "someClass.h"
someClass::someClass()
{
m_sword = new sword;
m_sword->name='s';
m_sword->str=5;
}
someClass::sword* someClass::returnSword()
{
return m_sword;
}
In case if my code is total nonsense, please explain how can I have a struct in my class, initialize it and then return a pointer from that class pointing to that struct.
Thank you.