База ответов ИНТУИТ

Язык программирования C++ для профессионалов

<<- Назад к вопросам

Что будет выведено на экран в результате выполнения приведенной ниже программы:

	#include "iostream.h"#include "conio.h"class NewClass{  int x;  int y;  public:  NewClass(int x0,int y0)  {    x=x0;    y=y0;  }  void DISPLAY(void)  {    cout<<x<<" "<<y;  }  NewClass operator+(NewClass obj)  {    NewClass tmp(0,0);    tmp.x=x+obj.x;    tmp.y=y+obj.y;    return tmp;  }};int main(){  NewClass obj1(1,3),obj2(5,8);  obj1=obj1+obj2;  obj1.DISPLAY();  getch();  return 0;}	

(Отметьте один правильный вариант ответа.)

Варианты ответа
7,1
1,3 5,8
6 11(Верный ответ)
Похожие вопросы

Что будет выведено на экран в результате выполнения приведенной ниже программы:

	#include "iostream.h"#include "conio.h"const int a=144;int main(){  a=12;  cout<<a;  getch();  return 0;}	

Правильно ли написан нижеприведенный программный код?

#include "iostream.h"#include "conio.h"int main(){  int x=17,y=46;  cout<<x<<"+"<<y<<"="<<x+y;  getch();  return 0;}	

Верен ли нижеприведенный код? Каков результат его работы?

#include <iostream>#include "conio.h"int main(){   enum {t, x, y, z ,w};  cout<<t+x+y+z+w;  getch();  return 0;}

Чему будет равняться значение переменной x после выполнения следующего кода:

#include "iostream.h"#include "conio.h"int main(){  int x=1;  M2:;  for(int i=1;i<5;i++,x++);  if(x>5)    goto M1;  else    goto M2;  M1: cout<<x;  getch();  return 0;}

Что выводит данная программа, если она верна?

#include <iostream.h>class Х{public:virtual void fun(int a = 0){cout << a;}};class Y: public X{public:virtual void fun(int a = 1) {cout << a ; }};int main(){X *px = new X;px->fun();X *py = new Y;py->fun();return 0;}	

Что будет напечатано в результате работы следующей программы?

  #include <iostream>  int f1(int x, int y)    {  return x + y; }  int f2(int x, int y)    {  return x * x + y * y; }  int (*pf1)(int, int);  int (*pf2)(int, int);  main()  { pf1 = &f1;    pf2 = &f2;    int x = 2, y = 3;    cout << (*pf1)(x, y) << ' ' << (*pf2)(x, y) << endl;  }  

Что будет напечатано в результате работы следующей программы?

  #include <iostream>  double s2(double x)    { return x*x; }  double s3(double x)    { return x*s2(x); }  double s4(double x)    { return s2(x)*s2(x); }  int main()  { typedef double (*PTF)(double);     PTF pf[3] = {&s2, &s3, &s4};     double x = 2;     for(int i = 0; i < 3; i++)         cout << (*pf[i])(x) << endl;     return 0;   }  

Что будет напечатано в результате работы следующей программы?

  #include <iostream>  #include <math>  double s2(double x)    {  return sqrt(x); }  double s3(double x)    {  return sqrt(s2(x)); }  double (*pf1)(double);  double (*pf2)(double);  main()  { pf1 = &s2;    pf2 = &s3;    cout << (*pf1)(25) << ' ' << (*pf2)(16) << endl;  }  

Что будет напечатано в результате работы программы:

  class A   { public: A() { cout << "A "; };            virtual A* new_A() { return new A(); }  };  class B : public A   { public: B(){ cout << "B " ;};            A* new_A() { return new B(); }  };  void fun(A* p1, A* p2)  { A* p3 = p1->new_A();    A* p4 = p2->new_A();  }  void main()  { A* p1 = new A;    B* p2 = new B;    fun(p1,p2);  }    

Какой результат будет у следующего выражения?

#include <iostream.h>short x = 11, i = 6;void fun1(){  if (i == (x-4)) throw 2; }void fun2(){ --x; fun1();  x++; }int main(){ try    { fun2(); }       catch (int)          { cout << "Exception "; }  cout << x << " " << i;  }