test/headers/default_arguments.h in rbplusplus-0.9 vs test/headers/default_arguments.h in rbplusplus-0.9.1
- old
+ new
@@ -19,13 +19,15 @@
class Tester {
public:
Tester() { }
- // Class methods
- std::string concat(std::string value1, std::string value2, const char* with = "-") {
- return value1 + std::string(with) + value2;
+ static std::string DEFAULT_WITH;
+
+ // Class methods
+ std::string concat(std::string value1, std::string value2, std::string with = default_args::Tester::DEFAULT_WITH) {
+ return value1 + with + value2;
}
// Class static methods
static std::string build(std::string base, int times = 3) {
std::string out = "";
@@ -34,16 +36,47 @@
}
return out;
}
};
+ std::string Tester::DEFAULT_WITH = std::string("-");
+ static std::string KICK_IT = std::string("kick-it");
+
+ // Make sure const and reference types are taken care of properly
+ //std::string build_strings(std::string value1, const std::string& with = default_args::KICK_IT) {
+ //return value1 + with;
+ //}
+
class Directed {
public:
// Director methods
virtual int virtualDo(int x, int y = 10) {
return x * y;
}
};
-
+
+ enum Ops {
+ ADD = 0,
+ REMOVE = 1
+ };
+
+ int modify(int value, Ops by = ADD) {
+ switch(by) {
+ case ADD:
+ return value + 10;
+ break;
+ case REMOVE:
+ return value - 10;
+ break;
+ }
+ return value;
+ }
+
+ // Seen in Ogre3D
+ int modify2(int value, Ops* by = 0) {
+ return value;
+ }
+
+
}
#endif // __DEFAULT_ARGS_H__