InterviewSolution
| 1. |
Solve : c++ in highschool? |
|
Answer» i am going into 9th grade and I want to know if that class would be too hard? Is c++ very hard? I dont know wether c++1 and 2 would be too much for 9th grade? Thanksif their offering it for your grade they probably aren't going to do anything beyond your abilities. BC Programmer: goodness no! actually... it doesn't even really work, since I couldn't be bothered to learn how to use a VARIANT in C++. So if the expression ends up returning a string or object it causes a PAGE fault. Oh well. As confusing as that may look, I have VB6 code that looks even worse... Public Sub InvokeDynamic(ByVal onObj As Object, ByVal memberName As String, Arguments As Variant, retval As Variant) Dim ArgsPass() As Variant Dim AccessMode As InvokeKinds Dim i As Long Dim Current As Long Dim TryEm(10) As InvokeKinds, TryCount As Long Dim MemberInf As TLI.SearchItem Dim FuncFlags As InvokeKinds Dim IntInfo As TLI.InterfaceInfo, Getfirst As Boolean On Error Resume Next Set IntInfo = TLI.InterfaceInfoFromObject(onObj) 'Set MemberInf=IntInfo.Members.GetFilteredMembers(False).Item( Set MemberInf = FindSearchItem(IntInfo.Members.GetFilteredMembers(False), memberName) If MemberInf Is Nothing Then ' 'check for existence of Get and Set prefixed names of this one... for example, if we were passed "Name" look for getName and setName. ' If StrComp(left$(memberName, 3), "Set", vbTextCompare) = 0 And StrComp(left$(memberName, 3), "Get", vbTextCompare) = 0 Then ' 'check for set/Get permutations. ' If Not IsArray(Arguments) Then ' 'try Get first. ' Getfirst = True ' Else ' Getfirst = False ' ' End If ' If Getfirst Then ' On Error Resume Next ' InvokeDynamic onObj, "Get" & memberName, Arguments, retval ' ' ' End If ' If Not Getfirst Or Err <> 0 Then ' Err.Clear ' InvokeDynamic onObj, "Set" & memberName, Arguments, retval ' ' ' ' ' ' End If ' 'Execution Error: METHOD or Data member not found. On Error GoTo 0 Err.Raise ExecuteErrors.Exec_UnsupportedOperation, "ModParser::InvokeDynamic", "Interface member name " & memberName & " Not present in class name " & TypeName(onObj) Else 'The method DOES exist. good. 'if we have an array of arguments, put them in reverse order for the InvokeHook... If IsArray(Arguments) Then ReDim ArgsPass(UBound(Arguments)) For i = UBound(Arguments) To 0 Step -1 If IsObject(Arguments(i)) Then Set ArgsPass(Current) = Arguments(i) Else ArgsPass(Current) = Arguments(i) End If Current = Current + 1 Next i End If 'OK, if we have no parameters, it is POSITIVE that, if it is a property, it will be the retrieval of it. 'with parameters, however, is a different story. we'll need to try a Put first, then a get if an error occurs. ' If IsArray(Arguments) Then 'An Array/ 'possibly Get/Put/PutRef/Function. 'INVOKE_PROPERTYPUT and INVOKE_PROPERTYPUTREF require arguments. If MemberInf.InvokeKinds And INVOKE_PROPERTYPUT And IsArray(Arguments) Then 'try Good ol' put first... TryEm(TryCount) = INVOKE_PROPERTYPUT TryCount = TryCount + 1 End If If MemberInf.InvokeKinds And INVOKE_PROPERTYPUTREF And IsArray(Arguments) Then TryEm(TryCount) = INVOKE_PROPERTYPUTREF TryCount = TryCount + 1 End If If MemberInf.InvokeKinds And INVOKE_PROPERTYGET Then TryEm(TryCount) = INVOKE_PROPERTYGET TryCount = TryCount + 1 End If If MemberInf.InvokeKinds And INVOKE_FUNC Then TryEm(TryCount) = INVOKE_FUNC TryCount = TryCount + 1 End If End If Dim CurrTry As Long 'Final Stage- Iterate through each item in TryEm from 0 to trycount and attempt an InvokeHook. For CurrTry = 0 To TryCount On Error Resume Next If UBound(ArgsPass) < 0 Then Err.Clear Call Assign(retval, CallByName(onObj, memberName, TryEm(CurrTry))) Else Call Assign(retval, TLI.InvokeHookArray(onObj, memberName, TryEm(CurrTry), ArgsPass)) End If If Err = 0 Then Exit For Err.Clear Next End Sub -reduced in size to keep from taking up the whole page. the PROJECT that this is in clocks in at 15,000 lines, but I'm pretty sure there's a bit of dead-code in there somewhere. Ahem... anyway... As long as you stay away from COM, C++ is really no trouble at all. It's when you start doing gross STUFF like my silly little sample that it get's tricky. In fact, I gave up on that one ages ago- I found it easier to find out how to make a console program in VB6...i just found my vb book. Take only one class, they'll teach you the basics starting from scratch. Because you're in grade nine they know there is no prerequisites to take before that, so you'll start with the basics. You're lucky you have C++ class in your high school, I only had Pascal and Java which became available a little bit to late for me.You're lucky to have any programming courses in your school. We don't have any - I have had to self-teach myself since i was seven. Useless northland schools...my school had "Information technology" for grades 10,11, and 12- (11 and twelve were mostly in Visual Basic, with some Flash thrown in for good measure), as well as AP CS 12, which I myself took in grade 11, and did nothing at all in and got 100%. Actually, come to think of it, I didn't do anything in any of those computer courses after the first day or so of IT11... technically I was silently upgraded to IT12 and even then I was far better at VB then anybody else in the school of 1400. I credit all this to my 386 and VB2 during summer holidays one year... Now the poor bastards there are using VS .NET... I actually visited there once, and I had to supress sarcastic laughter when they asked wether I used VB .NET. "As my main language. I find the .NET framework clunky and an unnecessary distributable, and the CLR to be a cheap copy of the Java VM. I prefer VB Classic. yourself?" That person spent the rest of that period trying to think of something that .NET could do that I not only couldn't do in VB6 but also hadn't done - didn't go over in his favour... |
|