Object Oriented Programming in C++: Lecture Plan and Exercises, Study notes of C programming

Notes for Beginners and made to study within a month

Typology: Study notes

2017/2018

Uploaded on 03/09/2018

choudharydevil
choudharydevil 🇵🇰

1 document

1 / 130

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
#
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f
pf40
pf41
pf42
pf43
pf44
pf45
pf46
pf47
pf48
pf49
pf4a
pf4b
pf4c
pf4d
pf4e
pf4f
pf50
pf51
pf52
pf53
pf54
pf55
pf56
pf57
pf58
pf59
pf5a
pf5b
pf5c
pf5d
pf5e
pf5f
pf60
pf61
pf62
pf63
pf64

Partial preview of the text

Download Object Oriented Programming in C++: Lecture Plan and Exercises and more Study notes C programming in PDF only on Docsity!

OBJECT ORIENTED

PROGRAMMING

Adeel M. Syed Adeel M. Syed [email protected] [email protected]

Introduction to Visual Studio .Net

  • (^) Visual Studio .NET is a complete set of development tools for building Web applications, XML Web services, Desktop applications, and Mobile applications.
  • (^) Visual Basic .NET, Visual C++ .NET, Visual C# .NET, and Visual J# .NET all use the same integrated development environment (IDE), which allows them to share tools and facilitates in the creation of mixed-language solutions.

Creating New Project :

  • (^) File – New – Project
    • (^) Project Types: Visual C++ Project
    • (^) Templates: Empty Project (.NET) Window Console 32 Application (Visual C++)
    • (^) Name: Project Name
    • (^) Location: Location to Save File – New – file File – New – file Categories: Categories: Visual C++Visual C++ Templates: Templates: C++ file (.CPP)C++ file (.CPP) Write Code & Save it at Appropriate location. Write Code & Save it at Appropriate location. File – Move Source1.CPP into Project File – Move Source1.CPP into Project Select Appropriate Project Name. Select Appropriate Project Name.

Structure (Contd.)

  • (^) Next to struct is structure name (or Tag).
  • (^) The declaration of the structure members are enclosed in braces.
  • (^) Each structure definition must end with a semicolon ;
  • (^) Two different structures may contain members of the same name.
  • (^) Members of the structure can be accessed by the DOT OPERATOR. (e.g. part.cost )
  • (^) Data members cannot be initialized in structure except “const static integral data members”.

struct dist { int feet; float inches; }; void main( ) { dist d1; cin>>d1.feet; cin>>d1.inches; dist d2 = { 30, }; cout<

Passing Objects to a

function:

Similar to passing variables to functions , one may pass the objects of a structure to a function. Vice Versa, objects can also be returned from a function.

Q1. Create a employee structure. The member data should comprise one integer for storing the employee id, one long integer for storing his salary, and a floating number for storing the employee’s pension. Create two functions, one for entering this data and other to display it. Write a main( ) that allows the user to call these functions.

Q3:

Write a C++ structure function which converts a sum of money given as an integer number of pence into a floating point value representing the equivalent number of pounds. For example 365 pence would be 3. pounds.

DEFAULT ARGUMENTS

Example: void repchar (char ch=‘x’, int val = 5) ; void main ( ) { repchar( ); repchar( ‘w’ ); \repchar( ‘t’ , 20 ); \repchar( 20 ); getch( ); } void repchar (char ch, int n) { for (int j=0 ; j

Class Assignment (Def. Arg.)

Calculation of Area of SQUARE, RECTANGLE and TRIANGLE. func1 ( ): Comparing condition & calling of function mydef( ) mydef( ): multiply all arguments and print result. main( ): calling func1.

  • (^) Overloading of functions with different return type is not allowed in C++.
  • (^) When an overloaded function is called, the correct function is selected by comparing their argument list.

Examples:

  • (^) void func ( );
  • (^) void func (int a);
  • (^) void func (float a, int b);
  • (^) void func (float a, float b);
  • (^) void func (int a, char b);
  • (^) int func (float a, float b); // illegal function