tailieunhanh - Creating Objects

An object is an instance of a class. You create objects to access member variables and member functions of a class. The chapter discusses how to declare variables. It also discusses how to write and execute C# program. | Creating Objects An object is an instance of a class. You create objects to access member variables and member functions of a class. The chapter discusses how to declare variables. It also discusses how to write and execute C program. Chapter 2 Objectives In this chapter you will learn to fl Declare variables fl Write and execute C programs Declaring Variables A variable is a location in the memory that has a name and contains a value. The value could be an integer such as 27 a decimal such as or a character such as L . A variable is associated with a data type that defines the type of data which can be stored in a variable. For example a variable called TennisPlayerName will ideally store characters whereas a variable called High_Score will store numbers. A program refers to a variable by its name. Naming Variables in C The following rules are used for naming variables in C Must begin with a letter or an underscore _ which may be followed by a sequence of letters digits 0-9 or underscores. The first character in a variable name cannot be a digit. Should not contain any embedded spaces or symbols such as @ - A . and . However an underscore can be used wherever a space is required like high_score. Must be unique. For example to store four different numbers four unique variable names need to be used. Uppercase letters are considered distinct from lowercase letters. Can have any number of characters. Keywords cannot be used as variable names. For example you cannot declare a variable named class because it is a keyword in C . The following are examples of valid variable names Game_level High_score This_variable_name_is_very_long The following are examples of invalid variable names score 2strank Note C is a case-sensitive language. This means that the variable TennisPlayerName is not the same as the variable tennisplayername. NIIT Creating Objects .

TÀI LIỆU LIÊN QUAN
crossorigin="anonymous">
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.