Before and after i++ or ++i before and after evaluation
Prefix (++x) involves more work than postfix (x++), at least on the surface and probably usually.
However, postfix does have it’s uses. The statements … cout << *iter << endl; ++iter; … can be replaced with … cout << *iter++ << endl;
$ ~ g++ -pg main.cpp -o my_program
$ ~ ./my_program; gprof call | head
$ ~
$ ~ valgrind ./program
$ ~ g++ -ggdb Main.cpp -o prog
$ ~ gdb prog
(gdb) break <function to stop>
(gdb) run
(gdb) where
(gdb) print <variable name> // check state of variable
template<typename T>
Number<T>::Number(const T& d)
{
theNumber = d;
}
template<class T> ostream& operator<< (ostream& out, const Number<T>& d)
{
out << d.theNumber;
return out;
}
int main()
{
Number<int> inum(10);
cout << inum << endl;
return 0;
}
#include<iostream>
using namespace std;
template <typename T, typename... Args>
void variadico(const T & t, const Args&... rest)
{
}
template<typename T>
ostream & print(ostream & os, const T & t)
{
return os << t << ".\n";
}
template<typename T, typename... Args>
ostream & print(ostream & os, const T & t, const Args&... the_rest)
{
os << t << ", ";
return print(os, the_rest...);
}
int main()
{
print(cout, "a", 3, 'F');
return 0;
}