Advertisement
shchuko

CodeStyleExample

Mar 13th, 2020
538
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.18 KB | None | 0 0
  1. // <---------- header.hpp
  2. #pragma once
  3.  
  4.  
  5. #inclide <some_lib.h>
  6.  
  7.  
  8. namespace MyNamespace {
  9.     /**
  10.      * Info about class
  11.      * @author Vasya Pupkin (email@email.info) 2020
  12.      */
  13.     class SomeClass {
  14.     private:
  15.         static constexpr int COMPILE_TIME_CONSTANT = 100000;
  16.    
  17.         // Initialized from constructor
  18.         static const int RUNTIME_CONSTANT;
  19.        
  20.         double z;
  21.    
  22.     public:
  23.         /**
  24.          * Info
  25.          * @param constant_value Sth about it
  26.          * @param z_value It's z_value woohoo_poohoo
  27.          */
  28.         SomeClass(int constant_value, double z_value)
  29.             : RUNTIME_CONSTANT(constant_value)
  30.             , z(z_value);
  31.  
  32.         /**
  33.          * Info
  34.          * @param z_new It's z_new woohoo_poohoo
  35.          */
  36.         void setZ(double z_new) noexcept;
  37.  
  38.         /**
  39.          * Info
  40.          * @return Z coordinate
  41.          */
  42.         double getZ() const noexcept;
  43.    
  44.         // Something else...
  45.  
  46.     protected:
  47.         // Protected methods..
  48.    
  49.     private:
  50.         // Private methods...
  51.     }
  52.  
  53. }
  54.  
  55.  
  56. // <---------- header.cpp
  57. #include "header.hpp"
  58.  
  59. MyNamespace::SomeClass::SomeClass(int constant_value, double z_value) {
  60.         // constructor body
  61. }
  62.  
  63. void MyNamespace::SomeClass::setZ(double z_new) noexcept {
  64.         z = z_new;
  65. }
  66.  
  67. int MyNamespace::SomeClass::getZ() const noexcept {
  68.     return z;
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement