TAILIEUCHUNG - Lecture Programming principles and practice using C++: Chapter 3 - Bjarne Stroustrup

Most programming tasks involve manipulating data. In this chapter, we will: Describe how to input and output data, present the notion of a variable for holding data, introduce the central notions of “Type” and “Type Safety”. | Chapter 3 Objects, types, and values Bjarne Stroustrup Abstract Most programming tasks involve manipulating data. Today, we will: describe how to input and output data present the notion of a variable for holding data introduce the central notions of “Type” and “Type Safety” Stroustrup/Programming/2015 Overview Strings and string I/O Integers and integer I/O Types and objects Type safety Stroustrup/Programming/2015 Input and output // read first name: #include "" // our course header int main() { cout > first_name; cout Stroustrup/Programming/2015 Overview Strings and string I/O Integers and integer I/O Types and objects Type safety Stroustrup/Programming/2015 Input and output // read first name: #include "" // our course header int main() { cout > first_name; cout Stroustrup/Programming/2015 Source files "" is the header for our course Interfaces to libraries (declarations) #include "" My code My data (definitions) : : Stroustrup/Programming/2015 Input and type We read into a variable Here, first_name A variable has a type Here, string The type of a variable determines what operations we can do on it Here, cin>>first_name; reads characters until a whitespace character is seen (“a word”) White space: space, tab, newline, Stroustrup/Programming/2015 String input // read first and second name: int main() { cout > first >> second; // read two strings string name = first + ' ' + second; // concatenate strings // separated by a space cout << "Hello, "<< name << '\n'; } // I left out the #include "" to save space and // reduce distraction // Don’t forget it in real code

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã 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.