C ++/MFC Questions
I. Fill in blank questions(26Minute)
1.Win32Platform,Sizeof (short) = __2__,Sizeof (INT) = __4__,Sizeof (long) = __4__.(3Minute)
2. Please provide the followingProgramResult(2Minute)
Int A = 3;
Int B = A <3;
A = __3__,B = __24__.
3 . Please The following program results are given:(2Minute)
Int AAA = 0x01;
Htonl (AAA) = _16777216___.// The running result shows 16777216, which may be a random value.
4. Please provide the following program results(2Minute)
# Define max_num 100 + 200
Int ntemp = max_num * 10;
ThenTemp = __2100__.
5. Please provide the following program results(3Minute)
Char sztemp [1000] = "";
Int nlen1 = sizeof (sztemp );
Int nlen2 = strlen (sztemp );
Strcpy (sztemp, "ABC ");
Int nlen3 = sizeof (sztemp );
Int nlen4 = strlen (sztemp );
Int ntemp [100];
Int * ptemp = ntemp;
Int nlen5 = sizeof (ptemp );
Char szresult [200] = "";
Sprintf (szresult, "% d, % 02d.", nlen1, nlen2, nlen3, nlen4, nlen5 );
ThenSzresult = ____.
6.MFCFrom which most classes inherit (Csf-target,Cobject,Cwinapp,Cwnd)?(2Minute)__Cobject__
7. Memory is the process rangeOrThread range;____
CPUDuring schedulingOrThread;____
Function call stack for processesOrThread.____ (3Minute)
8. Call the FunctionBbbWhat is the output?(4Minute)
Void CCC (int x)
{
Char sztemp [10] = "";
X = 2;
Sprintf (sztemp, "% d,", X );
Afxdump <sztemp;
If (x = 3)
{
Int x = 4;
Sprintf (sztemp, "% d,", X );
Afxdump <sztemp;
}
Sprintf (sztemp, "% d,", X );
Afxdump <sztemp;
}
Void BBB ()
{
Char sztemp [10] = "";
Int x = 7;
CCC (X );
Sprintf (sztemp, "% d,", X );
Afxdump <sztemp;
}
2. correct questions(Total15Minute,Each question5Minute).
1. BelowCodeError
Void func1 ()
{
Int * pA = NULL;
Func2 (PA );
Delete Pa;
}
Void func2 (int * pb)
{
PB = new int (5 );
}
2. What are the following code errors?
Void func2 (int * value)
{
* Value = 2;
}
Void func1 ()
{
Int * p = 0;
Func2 (P );
}
3.
Int func1 (Int & B)
{
Return 0;
}
Void func2 ()
{
Int BBB = 3;
Func1 (& BBB );
Func1 (BBB );
}
Func2What are the errors,Func1ParametersB.
Iii. Short answer(64Minute)
1.Brief IntroductionC,C ++,VC,MFCConceptual differences(4Minute)
2. Write a simple example of function overloading.(4Minute)
3.Which function is used to start new processes and threads.(4Minute)
4. sendmessageAndPostmessageWhat is the difference?(4Minute)
5. waitforsingleobjectWhat is the function;M_pthrdIsCwinthread *,Waitforsingleobject (m_pthrd-> m_hthread, infinite );What is the function.(4Minute)
6. _ stdcall,_ Cdecl,_ PascalWhat are the differences.(4Minute)
7. Add the following code for exception handling.(6Minute)
Int mywritefile (cstring strfilename, cstring strtext)
{
Int nret = 0;
Cfile myfile;
Myfile. Open (strfilename, cfile: modewrite | cfile: Export exclusive | cfile: modecreate, null );
Int nlen = strtext. getlength ();
Myfile. Write (char *) (lpcstr) strtext, nlen );
Myfile. Close ();
Return nret;
}
8. Please explain"Func"What type, what is the role of this type, variablesTttWhat is the value?(6Minute)
Typedef int (* func) (INT, int *);
Int XXX (int A, int * P)
{
Return A + * P;
}
Int dowork (func AAA, int BBB, int * CCC)
{
Return AAA (BBB, CCC );
}
Int SSS = 4;
Int TTT = dowork (& XXX, 3, & SSS );
9. Please refer to the following code:: Int operator + (...?ThisWhat is it?CCCWhat is the final value?(6Minute)
Class fruit
{
Public:
Fruit ()
{
Weight = 2;
}
Fruit (int w)
{
Weight = W;
}
Int operator + (fruit F)
{
Return this-> weight * F. weight;
}
PRIVATE:
Int weight;
};
Fruit AAA;
Fruit BBB (4 );
Int CCC = aaa + BBB;
10.Which of the following code is used?C ++Feature (CWhat is the role of a language?(6Minute)
Template <typename T>
T Sum (t a, t B)
{
Return (A + B );
}
11. Please explainAAA. hFunction of the following code(5Minute)
# If! Defined (afx_mysudu_h00009b952bea_a051_4026_b4e5_0598a39d2da40000included _)
# Define afx_mysudu_h00009b952bea_a051_4026_b4e5_0598a39d2da40000included _
......
# Endif
12.CmemorystateWhat are the main functions?(5Minute)
13. Read the following code to write the program execution result (6Points)
# Include <iostream>
Using namespace STD;
Class cbase
{
Public:
Virtual void print ()
{
Cout <"base" <Endl;
}
Void doprint ()
{
Print ();
}
};
Class cchild1: Public cbase
{
Public:
Virtual void print ()
{
Cout <"Child1" <Endl;
}
};
Class cchild2: Public cbase
{
Public:
Virtual void print ()
{
Cout <"child2" <Endl;
}
};
Void doprint (cbase * Base)
{
Base-> doprint ();
}
Void main ()
{
Cbase * base = new cbase ();
Cchild1 * Child1 = new cchild1 ();
Cchild2 * child2 = new cchild2 ();
Doprint (Child1 );
Doprint (child2 );
Doprint (base );
Delete base;
Base = Child1;
Base-> Print ();
Delete Child1;
Delete child2;
}