namespace myNamespace { }
within the class gives an error
g++ -DNOWARNDRMT -Wall -Wextra -o 2dmera 2dmera.cpp -litpp
./qubit_gate.cpp:476: error: expected unqualified-id before
'namespace'
make: *** [2dmera] Error 1
nike:mera2d carlosp$
What would be the best way to organize my big class??? (I am still
sort of rookie in c++)
Thanks!
That's right, namespaces inside classes are not allowed, and when you
think about, this wouldn't make much sense. What would like to achieve
with namespaces inside classes?
> What would be the best way to organize my big class??? (I am still
> sort of rookie in c++)
This depends. Having a class with 100 methods doesn't have to be bad
design (the CWnd class of MS's MFC has about this number of methods).
In general, however, a class with too many methods is a strong
indicator of bad design. In such a case you should try to separate the
class into several classes, each of them with a smaller coherent
interface. If your source code is not confidential, you could post a
small snapshot of the class so that we can help you better.
Regards,
Stuart
Thank you very much. well actually it has a big number of small
routines that move sutff and so on. I am not really willing to create
new clases, that seems to be to much of an effort.
So in order to have it available everywhere I have it in a svn server.
It cannot be compiled as it is downloaded as it requires some other
files that are not there. Still you can take a look. The file I want
to organize is "qubit_gate.cpp". I am also looking forward to any
suggestions regarging programing style!
Download with
svn co https://mera2d.svn.sourceforge.net/svnroot/mera2d
Thanks,
Carlos
Is the class concerned with exactly one thing? If not, then you realy
should consider separating your concerns, possibly moving members into
new classes which stand-alone, and using composition.
How much effort is it to create new classes, really? Adding namespaces
won't actually improve your design, but splitting the class into several
classes -- each with their own core concern -- likely will improve it
significantly.
Also, think about this: Code is read and modified a lot more often than
it is written. If you don't spend a little extra time/effort to make it
clean now, you'll spend a lot of time and effort to deal with it later.
--
Daniel Pitts' Tech Blog: <http://virtualinfinity.net/wordpress/>
Thanks a lot! I will consider your suggestion, though its not clear
for me at this point how to proceed, regarding design. I guess I'll
have to think a bit...
Thanks for your help!