某公司笔试(10)
  1. 请写出输出结果______(4 分)
#include <stdio.h>
union
{
    int i;
    char x[2];
}

void main()
{
    a.x[0] = 10;
    a.x[1] = 1;
    printf("%d", a.i);
}
  1. int Func(int,int); 不可与下列哪个函数构成重载 (______________)(4分)
  • A.int Func(int, int, int);
  • B.double Func(int, double);
  • C.double Func(double, double);
  • D.double Func(int, int);
  1. this 指针存在的目的是 () (4分)
  • A.保证基类公有成员在子类中可以被访问
  • B.保证基类私有成员在子类中可以被访问
  • C.保证基类保护成员在子类中可以被访问
  • D.保证每个对象拥有自己的数据成员,但共享处理这些数据成员的代码
  1. 在哪种派生方式中,派生类可以访问基类中的 protected 成员 (_) (4 分)
  • A.protected 和 private
  • B.public 和private
  • C.摞代ubli狡疤孩和 protected
  • D.仅protected
  1. 以下两条输出语句分别输出什么? (8 分)
float a = 1.0f;
float b = 0.0f;
  • A.cout « boolalpha « ( (int)a == (nt&)a ) « endl;___________________________
  • B.cout « boolalpha « ( (int)b == (int&)b ) « endl;___________________________
  1. 输出下面程序的输出结果。
#include <iostream.h>
template<class T>
class Sample
{
    T n;
    public:
    Sample(T i)
    {
        n = i;
    }
    int operator==(Sample&);
}

template<class T>
int Sample<T>::operator==(Sample& s)
{
    if(n==s.n)
    return l;
    else
    return 0;
}
void main()
{
    Sample<double> s1(2.5)s2(2.5);
    cout<<"s1与 s2 的数据成员"<<(sl==s2 ?"相等":"不相等")<<endl;________________________________
    Sample<int> s3(2)s4(3);
    cout<<"s3与s4 的数据成员"<<(s3==s4?"相等":"不相等")<<endl;_________________________________
}
  1. 以下三条输出语句分别输出什么?(9 分)
char str1[] = "abc";
char str2[] = "abc";
const char str3[] = "abc";
const char str4[] = "abc";
const char* str5 = "abc";
const char* str6 = "abc";
  • A.cout « boolalpha «( strl==str2 ) « endl;____________
  • B.cout « boolalpha «( str3==str4 ) « endl;____________
  • C.cout « boolalpha «( str5==str6 )« endl;____________
  1. 检查ABCD 四个表达式的是否正确,著正确,写出经过表达式中 的值,老不正确,请写出原团(2 分)
int a = 4;
  • A.a += (a++);_________
  • B.a += (++a);_________
  • C.(a++)+=a;_________
  • D.(++a)+=(a++);_________
  1. 关键宇explicit 有什么作用?(4分)

  2. 请写出输出结果:

#include<iostream>
using namespace std;
const char a ='';
const char b='*';
int main(int argc, char* argv[])
{
    char str[31] = "Sorry, what's your name again?";
    char* p = str + sizeof(str) - 2;
    char*q = p + 1;
    while (str != p--)
    {
        if(a == *p)
        {
            for (int i= l;p + i != q; ++i)
            {
                cout << *(p + i);
            }
            cout << b;
            q = p;
        }
        if(str == p)
        {
            for (int i= 0; p + i != q; ++i)
            {
                cout << *(p + i);
            }
        }
    }
    return 0;
}
  1. 判断字符串是否为回纹(写出伪代码即可)
bool isSymmerty(const char* p)
{
    
}
  1. 编程:如何判断一个单链表是否是环形链表?(7 分)(写出伪代码)
struct node
{
    char val;
    node* next;
}
bool check(const node* head)
{

}
  1. 设计程序:A文件中有一组整数,要求使用冒泡排序后输出到另一个文件中(20分)