>Concorsi
>Forum
>Bandi/G.U.
 
 
 
 
  Login |  Registrati 
Elenco in ordine alfabetico delle domande di 70-016: Desktop applications with Microsoft Visual C++ 6.0

Seleziona l'iniziale:
A   B   C   D   E   F   G   H   I   J   K   L   M   N   O   P   Q   R   S   T   U   V   W   X   Y   Z  

> Clicca qui per scaricare l'elenco completo delle domande di questo argomento in formato Word!


Examine the following code:


class A
{
public:
A() { cout << "ctor A\n"; }
~A() { cout << "dtor A\n"; }
};

class B : public A
{
public:
B() { cout << "ctor B\n"; }
~B() { cout << "dtor B\n"; }
};

class C : public B
{
public:
C() { cout << "ctor C\n"; }
~C() { cout << "dtor C\n"; }
};

int main()
{
C c; // object 1
A *a = new C; // object 2
delete a;
return 0;
}



What is displayed?

   

ctor A
Examine the following table named “Employees”, which is stored in a SQL Server 7 database:


EmpNumber  EmpName  EmpSalary
10 Ann 34925
20 Sue 37900
30 Bob 40100
40 John 32500
50 Kathy 39000


You have two valid ADO smart pointers. The first one, spCmd, points to a Command object, and the other one, spRsEmp, points to a Recordset object. Which of the following code examples will locate Bob?


// Example 1
spCmd->CommandText =
"SELECT * from employees ";
spRsEmp->Open((IDispatch *) spCmd,
vtMissing, adOpenForwardOnly,
adLockReadOnly, adCmdText);
spRsEmp->MoveFirst();
_bstr_t bstrFind("EmpNumber = 30");
spRsEmp->Find(bstrFind, 0,
adSearchForward);

// Example 2
spCmd->CommandText =
"SELECT * from employees "
"WHERE EmpNumber = ?";
long id = 30;
ParameterPtr spNumber =
spCmd->CreateParameter("EmpNumber",
adInteger, adParamInput,
4, id);
spCmd->Parameters->Append(spNumber);
spRsEmp->Open((IDispatch *) spCmd,
vtMissing, adOpenForwardOnly,
adLockReadOnly, adCmdText);

// Example 3
spCmd->CommandText =
"SELECT * from employees ";
spRsEmp->Open((IDispatch *) spCmd,
vtMissing, adOpenForwardOnly,
adLockReadOnly, adCmdText);
spRsEmp->MoveFirst();
spRsEmp->Find("EmpNumber = 30", 0,
adSearchForward);

// Example 4
spRsEmp->Open(
"SELECT * from employees "
"WHERE EmpNumber = 30",
"Data Source=ExamCram;uid=sa;pwd=",
adOpenForwardOnly, adLockReadOnly,
adCmdText);

   All four examples
Examine the following table named “Employees”:


EmpNumber  EmpName  EmpSalary
10 Ann 34925
20 Sue 37900
30 Bob 40100
40 John 32500
50 Kathy 39000


If the following code example is run, who will be the highest-paid employee?


_ConnectionPtr spConn(__uuidof(Connection));
try
{
spConn->ConnectionString =
"Data Source=ExamCram;uid=sa;pwd=";
spConn->Open("", "", "",
adConnectUnspecified);

_CommandPtr spCmd(__uuidof(Command));
spCmd->ActiveConnection = spConn;
spCmd->CommandText =
"SELECT * from employees "
"WHERE EmpSalary < ?";

_ParameterPtr spSalary =
spCmd->CreateParameter("EmpSalary",
adCurrency,
adParamInputOutput,
6,
40000.00);
spCmd->Parameters->Append(spSalary);

_RecordsetPtr spRs(__uuidof(Recordset));
spRs->CursorLocation = adUseClient;
spRs->Open((IDispatch *) spCmd, vtMissing,
adOpenStatic, adLockBatchOptimistic,
adCmdUnspecified);

for(spRs->MoveFirst();
!spRs->EndOfFile;
spRs->MoveNext())
{
double salary =
spRs->GetFields()->
GetItem("EmpSalary")->Value;
if(salary >= 38000.0)
salary *= 1.03;
else if(salary >= 35000.0)
salary = salary * 1.04 + 1000;
else if(salary >= 30000.0)
salary = salary * 1.05 + 1500;
else
salary = salary * 1.06 + 2000;
}
spRs->UpdateBatch(adAffectAll);
spRs->Close();
}
catch (_com_error &e)
{
...

   Bob