C++ programming style

前端 未结 16 1974
眼角桃花
眼角桃花 2021-02-07 22:33

I\'m an old (but not too old) Java programmer, that decided to learn C++. But I have seen that much of C++ programming style, is... well, just damn ugly!

All that stuff

16条回答
  •  刺人心
    刺人心 (楼主)
    2021-02-07 22:44

    That's not ugly at all. I would say it is... mhhh different. Bringing your old style to a new platform, that's ugly (I have had a lot of discussions about this with Mr. Skeet).

    Remember Java was defined years after C++, so it is reasonable they've fixed some constructs (in the same fashion C# learn from Java).

    So, I would suggest to keep in that C++ style.

    Think about this. Header files are like interface declarations and cpp files are implementation.

    I think C++ does not have "interface" keyword, and this is the way you separate the interface of a class from its implementation. Similar to this in Java:

    public interface Some { 
        public void method();
    }
    
    public class SomeImpl implements Some { 
        public void method(){}
    }
    

提交回复
热议问题