Managing C++ CHRIS DAHLBERG MID-TIER DEVELOPER SCOTTRADE.

Slides:



Advertisements
Similar presentations
Computer Programming and Basic Software Engineering 9 Building Graphical User Interface Developing a Simple Graphical User Interface (GUI)
Advertisements

CHARLES UNIVERSITY IN PRAGUE faculty of mathematics and physics C# Language &.NET Platform 6 th Lecture Pavel Ježek
Portability and Safety Mahdi Milani Fard Dec, 2006 Java.
The Type System1. 2.NET Type System The type system is the part of the CLR that defines all the types that programmers can use, and allows developers.
CS 4800 By Brandon Andrews.  Specifications  Goals  Applications  Design Steps  Testing.
Chapter 3 Data Abstraction: The Walls. © 2005 Pearson Addison-Wesley. All rights reserved3-2 Abstract Data Types Modularity –Keeps the complexity of a.
C#/.NET Jacob Lewallen. C# vs.NET.NET is a platform. Many languages compile to.NET: –VB.NET –Python.NET –Managed C++ –C#
Data Abstraction and Object- Oriented Programming CS351 – Programming Paradigms.
Chapter 11: Classes and Data Abstraction
Lecture 9 Concepts of Programming Languages
Introduction to Classes and Objects CS-2303, C-Term Introduction to Classes and Objects CS-2303 System Programming Concepts (Slides include materials.
Abstract Data Types and Encapsulation Concepts
Peter Juszczyk CS 492/493 - ISGS. // Is this C# or Java? class TestApp { static void Main() { int counter = 0; counter++; } } The answer is C# - In C#
Platforms and tools for Web Services and Mobile Applications Introduction to C# Bent Thomsen Aalborg University 3rd and 4th of June 2004.
From C++ to C#. Web programming The course is on web programming using ASP.Net and C# The course is on web programming using ASP.Net and C# ASP.Net is.
Differences between C# and C++ Dr. Catherine Stringfellow Dr. Stewart Carpenter.
Programming Languages and Paradigms Object-Oriented Programming.
Overview of Previous Lesson(s) Over View  OOP  A class is a data type that you define to suit customized application requirements.  A class can be.
Chapter 9 Defining New Types. Objectives Explore the use of member functions when creating a struct. Introduce some of the concepts behind object-oriented.
Distributed Systems (236351) Tutorial 1 - Getting Started with Visual Studio C#.NET.
Managed C++. Objectives Overview to Visual C++.NET Concepts and architecture Developing with Managed Extensions for C++ Use cases Managed C++, Visual.
Algorithm Programming Bar-Ilan University תשס"ח by Moshe Fresko.
Introduction to C# C# is - elegant, type-safe, object oriented language enabling to build applications that run on the.NET framework - types of applications.
Object-Oriented Programming in C++
C# D1 CSC 298 Elements of C# code (part 2). C# D2 Writing a class (or a struct)  Similarly to Java or C++  Fields: to hold the class data  Methods:
tom perkins1 XML Web Services -.NET FRAMEWORK – Part 1 CHAPTER 1.1 – 1.3.
Learners Support Publications Classes and Objects.
Classes In C++ 1. What is a class Can make a new type in C++ by declaring a class. A class is an expanded concept of a data structure: instead of holding.
Introduction to C#. Why C#? Develop on the Following Platforms ASP.NET Native Windows Windows 8 / 8.1 Windows Phone WPF Android (Xamarin) iOS (Xamarin)
C# Classes and Inheritance CNS 3260 C#.NET Software Development.
Introduction to c++ programming - object oriented programming concepts - Structured Vs OOP. Classes and objects - class definition - Objects - class scope.
1 Chapter Four Creating and Using Classes. 2 Objectives Learn about class concepts How to create a class from which objects can be instantiated Learn.
Chapter 10: Classes and Data Abstraction. Objectives In this chapter, you will: Learn about classes Learn about private, protected, and public members.
CS-1030 Dr. Mark L. Hornick 1 Basic C++ State the difference between a function/class declaration and a function/class definition. Explain the purpose.
 In the java programming language, a keyword is one of 50 reserved words which have a predefined meaning in the language; because of this,
Object Oriented Software Development 4. C# data types, objects and references.
Session 1 C# Basics.
Introduction to C# By: Abir Ghattas Michel Barakat.
C++ Programming: From Problem Analysis to Program Design, Fourth Edition Chapter 12: Classes and Data Abstraction.
C++ Programming: From Problem Analysis to Program Design, Fifth Edition Chapter 05: Classes and Data Abstraction.
Object Oriented Programming Session # 03.  Abstraction: Process of forming of general and relevant information from a complex scenarios.  Encapsulation:
CHARLES UNIVERSITY IN PRAGUE faculty of mathematics and physics C# Language &.NET Platform 4 th Lecture Pavel Ježek
Chapter 10: Classes and Data Abstraction. Classes Object-oriented design (OOD): a problem solving methodology Objects: components of a solution Class:
1 C# - Inheritance and Polymorphism. 2 1.Inheritance 2.Implementing Inheritance in C# 3.Constructor calls in Inheritance 4.Protected Access Modifier 5.The.
Basic Syntax อ. ยืนยง กันทะเนตร คณะเทคโนโลยีสารสนเทศและการสื่อสาร มหาวิทยาลัยพะเยา Chapter 2.
Reference Types CSE301 University of Sunderland Harry R Erwin, PhD.
C# Fundamentals An Introduction. Before we begin How to get started writing C# – Quick tour of the dev. Environment – The current C# version is 5.0 –
UMass Lowell Computer Science Java and Distributed Computing Prof. Karen Daniels Fall, 2000 Lecture 10 Java Fundamentals Objects/ClassesMethods.
Java and C# - Some Commonalities Compile into machine-independent, language- independent code which runs in a managed execution environment Garbage Collection.
FASTFAST All rights reserved © MEP Make programming fun again.
Value Types. 2 Objectives Discuss concept of value types –efficiency –memory management –value semantics –boxing –unboxing –simple types Introduce struct.
INTRODUCTION BEGINNING C#. C# AND THE.NET RUNTIME AND LIBRARIES The C# compiler compiles and convert C# programs. NET Common Language Runtime (CLR) executes.
Chapter 2 Objects and Classes
Jim Fawcett CSE687 – Object Oriented Design Spring 2015
Konstantinos pantos Software solutions architect Techaholics
C# for C++ Programmers 1.
Jim Fawcett CSE775 – Distributed Objects Spring 2009
Jim Fawcett CSE687-OnLine – Object Oriented Design Summer 2017
Jim Fawcett CSE687 – Object Oriented Design Spring 2016
Computer Programming and Basic Software Engineering 9 Building Graphical User Interface Developing a Simple Graphical User Interface (GUI)
Jim Fawcett CSE687 – Object Oriented Design Spring 2009
Built-In (a.k.a. Native) Types in C++
Classes and Objects.
Programming and Debugging
2. Second Step for Learning C++ Programming • Data Type • Char • Float
Data Structures and ADTs
C# Language & .NET Platform 9th Lecture
Jim Fawcett CSE681 – Software Modeling and Analysis Fall 2006
Introduction to Classes and Objects
Presentation transcript:

Managing C++ CHRIS DAHLBERG MID-TIER DEVELOPER SCOTTRADE

Platinum Sponsors Silver Sponsors Gold Sponsors

History of C++/CLI Visual Studio.NET (2002) ◦Managed Extensions for C++ introduced Visual Studio 2005 ◦C++/CLI introduced as the successor to Managed C++ ◦Improved syntax Visual Studio 2010 ◦No IntelliSense support for C++/CLI Visual Studio 2012 ◦IntelliSense support restored!

What is C++/CLI? CLI = Common Language Infrastructure Visual C++ with.NET extensions Typically follows an It Just Works approach

What can C++/CLI Do? Use native C++ code and code libraries Use managed assemblies Create mixed-mode assemblies ◦Contain both native and managed code ◦Compiled with /clr Create purely managed assemblies ◦Contains only managed (verifiably type-safe) code ◦MSIL ◦Compiled with /clr:pure

Why use C++/CLI? Simplicity and maintainability ◦No need to generate or regenerate COM interops ◦No need to register COM libraries ◦No need to manually define or update P/Invoke calls ◦Can use native and managed libraries from native and managed code ◦Can convert native code to managed code (or vice-versa) gradually Reliability ◦Compile-time feedback

Creating a New C++/CLI Project

Hello, World!

Modifying an Existing VC++ Project

Basic Data Type Equivalencies C++C#C++C# bool [signed] charsbyteunsigned charbyte [signed] shortshortunsigned shortushort [signed] int / longintunsigned int / longuint [signed] long longlongunsigned long longulong float double wchar_tchar

Syntax Summary Syntax for native items is unchanged Many items have no distinction of native vs. managed ◦Namespaces ◦Declaring local variables and class members* ◦*Except for managed pointers or references ◦Assignment ◦Mathematical and Logical Operators ◦Using template/generic types ◦Accessing Members

Defining Types The class and struct keywords retain their C++ meanings ◦Default visibility of class is private ◦Default visibility of struct is public Type visibility modifiers ◦Default is private, equivalent to internal in C# ◦Can specify two visibility modifiers ◦“public protected” is equivalent to “internal protected” in C#

Defining Enumerations “enum [class|struct]” ◦Equivalent to “enum” in C# ◦No difference between “enum class” and “enum struct” Managed enums are also exposed as native enums

Defining Interfaces “interface [class|struct]” ◦Equivalent to “class” in C# ◦No difference between “interface class” and “interface struct” from a managed perspective

Defining Value Types “value [class|struct]” is used to define value types ◦Equivalent to “struct” in C# ◦No difference between “value class” and “value struct” from a managed perspective

Defining Reference Types “ref [class|struct]” is used to define reference types ◦Equivalent to “class” in C# ◦No difference between “ref class” and “ref struct” from a managed perspective

Using Managed Types Variables and fields are declared and used the same way

Managed References Declaring reference uses “%” instead of “&” Equivalent to “ref [className]” in C# No concept of const references

Managed Pointers Declaring pointers to managed objects uses “^” instead of “*”

Memory Details Stack semantics for reference types ◦Automatically call Dispose ◦Still actually allocated on the managed heap Restrictions ◦Native objects containing managed state ◦Managed objects containing native state

IDisposable and Destructors IDisposable is implicitly implemented when a managed class has a destructor Used to dispose any managed resources ManagedClass::~ManagedClass() { }

Finalizers Used to clean up native resources ManagedClass::!ManagedClass() { }

Marshalling Conversion from managed to unmanaged type std::string to System::String^, for example

Exception Handling Very similar to C++ exception handling Can also catch managed exceptions ◦All inherit from System::Exception

Code Documentation Same as C# Must enable the /doc compiler option

Limitations Cannot create AnyCPU mixed-mode assemblies ◦Can create pure MSIL assemblies using /clr:safe Cannot create static libs Header files referenced by native projects must not contain any managed components ◦That includes forward-declarations of managed types