i have class a implemented files a.hpp , and a.cpp.
1 of methods of class a receives message, translates , stores structure.
method signature looks , method public:
eretcode a::parseinfo(sometype* pmessage, tparsedinfofroma& parsedinfo); in opinion tparsedinfofroma type should defined (using typedef) @ a.hpp since relevant class , meaningless without class.
simplest way define above class.
however, feel file a.hpp should begin declaration of class a.
typedef of structure appear after class declaration.
does c++ provide me legitimate way (not "ugly" trick) indicate tparseddatafroma defined below can use reference structure of type tparsedinfofroma @ declaration of parseinfo method?
tried forward declaration compiler won't have it.
would appreciate comments
assuming class a has no member, method return or parameter of type tparsedinfofroma (only tparsedinfofroma& or tparsedinfofroma*), , provide implementation class in cpp file, can achieve want.
in header, forward declare struct as:
struct tparsedinfofroma; then, define class a:
class { eretcode a::parseinfo(sometype* pmessage, tparsedinfofroma& parsedinfo); // ... }; then, define struct:
struct tparsedinfofroma { // ... }; some thoughts, though. if tparsedinfofroma (not best name assume actual name better) consists of few members, makes sense have defined before a. if longer, you'd better have in separate file. lastly, if feel definition struct undissociable of class, can declare struct nested in a.
class { struct tparsedinfofroma { // struct members } eretcode a::parseinfo(sometype* pmessage, tparsedinfofroma& parsedinfo); // class members };
Comments
Post a Comment