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

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

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

Какая строка данного кода производит возврат элемента по указателю?

#define SIZE 100int Stack[SIZE]; int SP; void lnit(){ SP = - 1 ; } void Push(int val) { Stack[ ++SP]=val; }int Рор() { if (SP < О ) return(O); return ( Stack[SP--]); }	

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

Варианты ответа
пятая
четвертая
девятая(Верный ответ)
вторая
Похожие вопросы

Что производит эта программа?

#include <fstream>#include <vector>#include <stack>using namespace std:int main(){ifstream in ("inpnum");stack <int. vector<int> > s;int x;while ( in >> x. !in.eof()) s.push(x);while (!s.empty()){X = s.top(); cout << x << " ";s.pop();return 0;}}	

Для чего предназначена следующая программа и верна ли она:

#include <iostream>#include <fstream>#include <vector>#include <stack>using namespace std;int main(){    ifstream in ("inpnum");    stack <int, vector<int> > s;    int x;    while (in >> x, !in.eof()) s.push(x);    while (! s.empty())    {        x = s.top(); cout << x << " ";        s.pop();    }}

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

  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"#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;}	

Укажите результат выполнения следующего кода:

	int factorial(int x){	if(x==1)		return 1;	else		return x*factorial(x-1);}int Func(int y){	y = factorial(3);	return y+10;}int _tmain(int argc, _TCHAR* argv[]){	int x = 0;	int z = 0;	z = Func(x);	printf("z=[%d] x=[%d]",z,x);	int i;		scanf("%d",&i);	return 0;}	

Интерфейс определен следующим образом:

  class X   { Y a; Z b;    void set(Y&);    public: void f(const char*);            void g(int[10], int);   }         
Какая проблема может возникнуть при его использовании?

Интерфейс определен следующим образом:

  class X   { Y* a; Z & b;     public:   void f(const char*);              void h(int, ...);              void g(int[10], int);   }  
Какая проблема из перечисленных ниже может возникнуть при его использовании?

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

#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;}	

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

  int SM(const int A[], int N)  { int S = A[0];    for (int i = 1; i < N; i++) S += A[i];    return S;  }    int main()  {   #define Bmax 6    int B[6] = {1, 2, 3, 4, 5, 6};    cout << SM(B + 3, Bmax - 3) << endl;    return 1;  }  

Какая строка данного кода производит специализацию шаблона?

template<class Т> class А{int х;};template<class Т> class А<Т*> { long х;};template<template<class U> class V> class C{V<int> y;V<int*> z;};C<A> c;