What  happens if you try to compile and run this program?

Last Updated on May 22, 2022 by Admin 3

What  happens if you try to compile and run this program?

#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
class A
{
  int a;
public:
  A (int a):a (a)
  {
  }
  int getA () const
  {
    return a;
  }
  void setA (int a)
  {
  this->a = a;
  }
  bool operator == (const A & b) const
  {
    return a == b.a;
  }
};
int
main()
{
  ​​cout << 31 << ", ";
  cout.setf (ios::hex, ios::basefield);
  cout.setf (ios::showbase); //LINE I
  cout << 31 << ", ";
  cout.unsetf (ios::showbase); //LINE II
  cout << 63 << ", ";
  return 0;
}
  • the program outputs 31, 31, 3f,
  • compilation error in LINE II
  • runtime error at LINE I
  • compilation error in LINE I 
  • the program outputs 31, 31, 63
  • the program outputs 31, 0x1f, 3f,
0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments