Is it possible to avoid repeating the class name in the implementation file?

后端 未结 8 2048
迷失自我
迷失自我 2020-11-27 21:39

Is there a way to avoid the Graph:: repetition in the implementation file, yet still split the class into header + implementation? Such as in:

Header Fi

8条回答
  •  甜味超标
    2020-11-27 22:05

    No there's not. Not directly at least. You could go for preprocessor tricks, but don't do it.

    #define IMPL Graph::
    
    IMPL Graph(int n){}
    void IMPL printGraph(){}
    void IMPL addEdge(){}
    void IMPL removeEdge(){}
    

    Also, you shouldn't even want to do it. What's the point. Besides it being a C++ rule, it lets you know you're actually implementing a member function.

提交回复
热议问题