Unused method arguments

I will get straight to it. Let's say I have the following method deceleration:

1
2
3
  QString makeVersionString(const CVersionTag* firmwareTag,
                            const CVersionTag* protocolTag,
                            bool               isCompatible)


Now if I call that method I need to send it three parameters two const's and a bool. Well how would I go about adding say a third value:

1
2
3
4
  QString makeVersionString(const CVersionTag* firmwareTag,
                            const ID*          someTag,
                            const CVersionTag* protocolTag,
                            bool               isCompatible)


in such a way so that if I don't provide it the new argument it won't give an error? This can be done in Python, can it be done with C++?
Last edited on
AFAIK you have to overload the method by writing two separate versions.
Ah okay, great ty.
It seems maybe it can be done without function overloading, unless I'm misunderstanding how variadic functions work. These resources might help. I have never used this method so I'm not familiar with this language feature at all.

https://www.cprogramming.com/tutorial/lesson17.html
http://www.cplusplus.com/reference/cstdarg/va_arg/
Is there a common method for documenting an overloaded method? For instance:

1
2
3
  QString makeVersionString(const CVersionTag* firmwareTag,
                            const CVersionTag* protocolTag,
                            bool               isCompatible)


1
2
3
4
5
6
7
  /**
   *This method has been overloaded for x reasons
   */
  QString makeVersionString(const CVersionTag* firmwareTag,
                            const ID*          someTag,
                            const CVersionTag* protocolTag,
                            bool               isCompatible)

Topic archived. No new replies allowed.