All 300/400 Level CS Major Courses Tutoring Location: SEC 3433 Sign up or walk-in Introduction2-1
Language and IDE C++/CLI language and.NET framework Examples in Microsoft Visual Studio 2012
Compiled Languages Compiler (Including Linker) hello.cpp (high level) hello.exe (machine) Result Executor hello.exe
Interpreted Languages Interpreter hello.bas Result
Compiled vs. Interpreted Advantages Disadvantages
Hybrid Compiler-Interpreter Interpreter Source code Result Compiler Intermediate language code
Java JRE/JVM Java Source Code Result Javac Java Bytecode
C++/CLI CLR C++/CLI Source Code Result C++/CLI compiler CIL Bytecode This applies to C# and VB.NET too. CLR = Common Language Runtime CIL = C++ Intermediate Language
About C++\CLI C++ (.h,.cpp, complied) C++/CLI (compiled to MSIL (Microsoft Intermediate Language), not machine code)(not interpreted at runtime) C++ vs. C++/CLI –Unmanaged code vs. managed code Managed code: memory management, code access security, multi-language integration –Garbage collection
.NET –Application development technologies –.NET base class library –Common Language Runtime (above OS)
.NET Advantages Language natural … MSIL –Many non-MS languages can use base class library –Common Type System (CTS) –Common Language Specification (CLS) Minimum subset of CTS for all the.NET compatible languages Platform independent … CLR –Port.NET Framework to non-Windows platform w/o recompiling –JIT: Just-In-Time Compilation –A JIT compiler translates bytecode into the native machine language.
IDE (Integrated development environment) Microsoft Visual Studio for C++
Obtain Microsoft Visual Studio 2012 (either Professional, or Ultimate) Visual Studio 2012 only: any student at UA at no cost. licensing/dreamspark-standard/ and scroll to the very end (click on the “WebStore” link in “Obtaining Software” licensing/dreamspark-standard/
Obtain Windows, Microsoft Visual Studio 2012 (either Professional, or Ultimate) OIT resources for licensed copies access software through DreamSpark –STEM departments: DreamSpark Premium No cost to eligible students Get help: –OIT service desk –CS : Jeremy LaGrone, jlagrone at cs ua edu
Examples How to use Microsoft Visual Studio 2012 Assignment: within next two weeks –Download and install Microsoft Visual Studio –If needed, Windows as well. –Use Visual Studio to create a project of CLR Console Application after this class Can use your current or later assignments
Create a CLR Console Application –Start Microsoft Visual Studio 2012 –Create a new project by selecting from the menu bar "FILE"-> "New"->"Project". In the "New Project" dialog box, select "Visual C++" under "Installed Templates" and select "CLR Console Application" as the project template. Enter C:\CS351\Projects (or any directory designated for keeping your CS351 projects) in the "Location" field, and First (or any project name) in the "Name" filed. It is better to uncheck "Create directory for solution". –Add code to the project. –Build. –Execute.
backups
Examples Quadratic Equation: ax 2 +bx+c=0 Discriminant: ∆=b 2 -4ac Two roots: x 1 = x 2 =
// Quadratic.cpp : main project file. #include "stdafx.h" using namespace System; int main(array ^args) { double a, b, c; Console::Write(L"Enter the quadratic coefficiet(a): "); a = Double::Parse(Console::ReadLine()); Console::Write(L"Enter the linear coefficnet(b): "); b = Double::Parse(Console::ReadLine()); Console::Write(L"Enter the constant term(c): "); c = Double::Parse(Console::ReadLine()); double discriminant; discriminant = b*b-4*a*c; double x1 = (-b+Math::Sqrt(discriminant))/(2*a); double x2 = (-b-Math::Sqrt(discriminant))/(2*a); Console::WriteLine(L"Two roots are " + x1 + " and " + x2); return 0; }
Play with code 1. Console application –Output more –Read so to pause Console::Write(L"Enter the constant term(terminate): "); Int c = Double::Parse(Console::ReadLine()); Console::Write(L"Verify"); Boolean y = Double::Parse(Console::ReadLine()); 2. Windows Form Application –Use different form name