Web Development

General discussion


Passing constants to functions

By miles.felton ·
The topic 'USE NON-CONSTANT LITERALS TO PASS CONSTANT REFERENCES, PART 1' is interesting. But don't forget that when you are writing your own library that you can make it so that your callers don't have do that. Here is an example:-
#include <iostream>
template <class T>
class cS
T fOutX(T&);
T fOutX(const T& iaX);
void main()
int iX = 125;
cS<int> csY;
template <class T>
T cS<T>::fOutX(T& iaX)
std::cout << iaX << std::endl;
return iaX;
template <class T>
T cS<T>::fOutX(const T& iaX)
T iX = iaX;
return fOutX(iX);

If you see what I mean.

This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Comments

Related Discussions

Related Forums