Hacker News new | past | comments | ask | show | jobs | submit login

I wasn't sure how const worked in this language so I decided not to mess with it yet.

Coming from Java I have a blanket policy that every variable is final unless needed to be modified. I've run into those pain points.

Your first observation is one I have some into as well but I haven't been taught how to do this.

For example if my header file needs to define the method:

   void test(std::string something);
Is it bad form to them define the header in my cpp file as such?

   void test(string something);
Isn't that also bad form? Coming from C some things like this could be done but very much shouldn't have been done.

I know for a fact that namespacing is one of the hugest benifits to large projects I just don't know how to use the tools provided by C++ to do it correctly. Java? Yea I can get anything you want nice and tucked away. But C++ with the way headers and namespacing works its difficult to obviously see what I want to do and how to get it done.

Any examples?




I'm not sure I understand the question completely. Do you mean "declare" instead of "define" in "if my header file needs to define the method"? Or are you asking about declaring the parameter to test as "std::string" in the header but then only as "string" in the .cpp definition, because of the presence of a using statement?




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: