Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

Should I have a prim.h and what about non-template code in prim.cpp?

code non-template
0
Posted

Should I have a prim.h and what about non-template code in prim.cpp?

0

Yes – you should write a .h (header) file for prim.cpp and it should contain at least the prototype for “computeMST”. Also if you have any “local” helping functions in the prim.cpp file then you may encounter some compiler errors (multiply defined things) – if this is the case you should remove those helping functions (the only time this is a problem is if they are non-template functions) and/or more those helping functions into another file (this is a little bit messy but necessary due to some cxx “magic” template issues). • I get a weird error saying “.. object has type qualifiers that are not compatible …” – help! MORE THAN LIKELY – the problem is that you have a CONST object and are calling a NON-const member function – you have TWO main options: • Make the member function const (this is the BEST option) if at all possible. • OR make the object non-const (this is an acceptable but not as good option) – OR ***COPY*** the CONST object into a non-const local variable and then use th

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123