Which of the following C++ code will give error on compilation? [code] ================code 1================= #include <iostream> using

Which of the following C++ code will give error on compilation?
Code:
================code 1=================
#include <iostream>
using namespace std;
int main(int argc, char const *argv[])
{
	cout<<"Hello World";
	return 0;
}
========================================
================code 2=================
#include <iostream>
int main(int argc, char const *argv[])
{
	std::cout<<"Hello World";
	return 0;
}
========================================
A. Both code 1 and code 2
B. Code 1 only
C. Code 2 only
D. Neither code 1 nor code 2
 
Answer: d
Explanation: Neither code 1 nor code2 will give error as both are syntactically correct as in first code we have included namespace std and in second one we have used scope resolution operator to resolve the conflict.
 

Tìm kiếm

Back
Top