Dario said:
So there are something that may be do in C++ and not in Java?
Interesting...
Please give me your curriculum, so I can hire you in my company!
///////////////////////////////////////////////////////////////////////////
[answer 1 - fun stuff ^_^]
#include <iostream>
int main()
{
using namespace std;
goto start;
done:
return 0;
last:
cout << "completely backwards! ^_^" << endl;
goto done;
next:
cout << "run a program ";
goto last;
start:
cout << "let's see java ";
goto next;
}
///////////////////////////////////////////////////////////////////////////
[answer 2 - template metaprogramming]
#include <iostream>
template <int N>
class compile_time_factorial
{
public:
static const int return_value =
compile_time_factorial<N - 1>::return_value * N;
};
template<>
class compile_time_factorial<0>
{
public:
static const int return_value = 1;
};
#define factorial(n) compile_time_factorial<n>::return_value;
int main()
{
using namespace std;
cout << "\n!3 = " << factorial(3);
cout << "\n!4 = " << factorial(4);
cout << "\n!5 = " << factorial(5);
return 0;
}
///////////////////////////////////////////////////////////////////////////
[answer 3 - templates period, java generics suck]
#include <iostream>
#include <string>
#include <sstream>
template <typename T>
class numbers_only_writer
{
// Leave blank for build time error
// or implement string write(T const&); that throws an
// exception for a compiler time error
};
#define NUMBER_WRITER_CLASS(T) template <> \
class numbers_only_writer<T> \
{ \
public: \
static std::string write(T const& t) \
{ \
std:
stringstream str; \
str << t; \
return str.str(); \
} \
}
NUMBER_WRITER_CLASS(int);
NUMBER_WRITER_CLASS(float);
NUMBER_WRITER_CLASS(unsigned short);
// etc.
#undef NUMBER_WRITER_CLASS
template <typename T>
inline std::string number_only_write(const T& t)
{
return numbers_only_writer<T>::write(t);
}
int main()
{
using namespace std;
cout << "int write: " << number_only_write(2) << endl;
cout << "float write: " << number_only_write(3.14f) << endl;
cout << "unsigned short write: " <<
number_only_write(static_cast<unsigned short>(2)) << endl;
//cout << "char write (uh oh!): " << number_only_write('c') << endl;
return 0;
}
///////////////////////////////////////////////////////////////////////////
[answer 4 - create executables that cannot be trivially decompiled]
///////////////////////////////////////////////////////////////////////////
[answer 5 - tell me what's in my cpu's edx register]
///////////////////////////////////////////////////////////////////////////
[answer 6 - write device drivers]
///////////////////////////////////////////////////////////////////////////
[answer 7 - run a reasonably interesting game on my gba]
i'll pass on that job offer, though. from what you've demonstrated of
the level of technical expertise there, i'm afraid it won't be around
long enough for me to make the walk over.
indi