Guest User

Untitled

a guest
Jun 14th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class TestStaticVariables
  5. {
  6. // Private member variable:
  7. static const double static_double_variable;
  8. public:
  9. // Constructor:
  10. TestStaticVariables()
  11. {
  12. // Initialization:
  13. static const double static_double_variable = 20.0;
  14. cout << static_double_variable;
  15. }
  16. // Member Function:
  17. void test();
  18. };
  19.  
  20. void TestStaticVariables::test()
  21. {
  22.  
  23. //cout << static_double_variable;
  24. }
  25.  
  26. int main(int argc, char* const argv[])
  27. {
  28.  
  29. TestStaticVariables test_instance;
  30.  
  31. return 0;
  32. }
  33.  
  34. #include <iostream>
  35.  
  36. class Foo {
  37. static const double _bar;
  38.  
  39. public:
  40. Foo();
  41.  
  42. void Bar();
  43. };
  44.  
  45. const double Foo::_bar = 20.0;
  46.  
  47. Foo::Foo() {
  48. std::cout << Foo::_bar << std::endl;
  49. }
  50.  
  51. void Foo::Bar() {
  52. std::cout << Foo::_bar << std::endl;
  53. }
  54.  
  55. int main( int argc, char *argv[] ) {
  56. Foo f;
  57. f.Bar();
  58.  
  59. return 0;
  60. }
  61.  
  62. // Initialization:
  63. static_double_variable = 20.0;
  64.  
  65. // Private member variable:
  66. static const double static_double_variable;
  67.  
  68. const double TestStaticVariables::static_double_variable = 20.0;
Add Comment
Please, Sign In to add comment