One Amazing C++ question that my friend +Abhinaba Basu asked me:
Write a program that prints "Hello" hundred times without using any loop or recursion statements and without writing the printing statement hundred times.
Hint : It is a c++ program
class Test
{
public:
Test()
{
std::cout << "Hello" <<>Now one follow up. He told me to optimize this.
Here we go....... (Simply, Add a destructor)
class Test
{
public:
Test()
{
std::cout << "Hello" << std::endl;
}
~Test()
{
std::cout << "Hello" << std::endl;
}
};
void main()
{
Test t[50];
}
Write a program that prints "Hello" hundred times without using any loop or recursion statements and without writing the printing statement hundred times.
Hint : It is a c++ program
class Test
{
public:
Test()
{
std::cout << "Hello" <<>Now one follow up. He told me to optimize this.
Here we go....... (Simply, Add a destructor)
class Test
{
public:
Test()
{
std::cout << "Hello" << std::endl;
}
~Test()
{
std::cout << "Hello" << std::endl;
}
};
void main()
{
Test t[50];
}
No comments:
Post a Comment