Skip to content

Commit 34fb3ed

Browse files
committed
Make methods in ClassExample static
The methods in the ClassExample and ClassExample2 classes have been made static. This includes the fundamentalTypeMethod, divideNumbers, passingUniquePointer, and passingObjectInGeneral methods. This change allows these methods to be called without having to instantiate an object of the class.
1 parent a549271 commit 34fb3ed

3 files changed

Lines changed: 9 additions & 9 deletions

File tree

‎ElementsExamples/ElementsExamples/ClassExample.h‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ class ELEMENTS_API ClassExample {
108108
* @return
109109
* The output of the method
110110
*/
111-
double fundamentalTypeMethod(const double input_variable) const;
111+
static double fundamentalTypeMethod(const double input_variable);
112112

113113
/**
114114
* @brief
@@ -126,7 +126,7 @@ class ELEMENTS_API ClassExample {
126126
* @throws
127127
* EuclidException, if the second number is (close to) zero
128128
*/
129-
double divideNumbers(const double first, const double second) const;
129+
static double divideNumbers(const double first, const double second);
130130

131131
/**
132132
* @brief
@@ -142,7 +142,7 @@ class ELEMENTS_API ClassExample {
142142
* @param vector_unique_ptr
143143
* Unique pointer to a vector object
144144
*/
145-
void passingUniquePointer(std::unique_ptr<std::vector<double>> vector_unique_ptr) const;
145+
static void passingUniquePointer(std::unique_ptr<std::vector<double>> vector_unique_ptr);
146146

147147
/**
148148
* @brief
@@ -157,7 +157,7 @@ class ELEMENTS_API ClassExample {
157157
* @param input_object
158158
* a vector of double
159159
*/
160-
void passingObjectInGeneral(const std::vector<double>& input_object) const;
160+
static void passingObjectInGeneral(const std::vector<double>& input_object);
161161

162162
/**
163163
* Getter to access private sourceId

‎ElementsExamples/ElementsExamples/ClassExample2.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ class ELEMENTS_API ClassExample2 {
9898
* @return
9999
* The output of the method
100100
*/
101-
double fundamentalTypeMethod(const double input_variable) const;
101+
static double fundamentalTypeMethod(const double input_variable);
102102

103103
/**
104104
* @brief

‎ElementsExamples/src/lib/default/ClassExample.cpp‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,26 +37,26 @@ namespace Examples {
3737

3838
const std::string ClassExample::s_static_string = "This is a static field example";
3939

40-
double ClassExample::fundamentalTypeMethod(const double input_variable) const {
40+
double ClassExample::fundamentalTypeMethod(const double input_variable) {
4141
return input_variable;
4242
}
4343

4444
/*
4545
* This is a silly example just to have a method throwing an exception
4646
*/
47-
double ClassExample::divideNumbers(const double first, const double second) const {
47+
double ClassExample::divideNumbers(const double first, const double second) {
4848
double tolerance = 1e-12;
4949
if (std::abs(second) < tolerance) {
5050
throw Elements::Exception() << "Dividing by " << second << " exception in ClassExample::divideNumbers(...)";
5151
}
5252
return first / second;
5353
}
5454

55-
void ClassExample::passingUniquePointer(std::unique_ptr<vector<double>> vector_unique_ptr) const {
55+
void ClassExample::passingUniquePointer(std::unique_ptr<vector<double>> vector_unique_ptr) {
5656
ELEMENTS_UNUSED auto vect_size = vector_unique_ptr->size();
5757
}
5858

59-
void ClassExample::passingObjectInGeneral(const vector<double>& input_object) const {
59+
void ClassExample::passingObjectInGeneral(const vector<double>& input_object) {
6060
ELEMENTS_UNUSED auto object_size = input_object.size();
6161
}
6262

0 commit comments

Comments
 (0)