| template T values[2]; public: mypair(T first, T second) { values[0]=first; values[1]=second; } }; |
Compile and Execute Java Online - Try and experience the best cloud computing where you can edit, compile, ... Compile Preview | Execute | Share Code.
Saturday, September 11, 2010
Lớp Template
Tương tự hàm template, ta cũng có khai báo lớp template tương tự.
Ta có thể sử hàm tạo với tham số first và second thuộc loại T bằng các tham số cụ thể được ấn định. Ví dụ mypair myobj(1, 2) sẽ sử dụng hàm tạo của lớp mypair để tạo lớp chứa hai đối tượng là 1 và 2 thuộc số nguyên.
Labels:
C++
Subscribe to:
Post Comments (Atom)
Popular Posts
-
Announcing hspec - BDD for Haskell I've long been interested in Behavior Driven Design and it's something that is strangely missing ...
-
This tutorial will be written in Java since I'm familiar with it and it's a decent enough language, has many tools and libraries, a ...
-
More vague notes about rogulikes; this time about monster difficulty or Power Curve . In I Rule, You Rule, We All Rule Old-School Hyrule th...
-
Let's say you're a developer on a C# app and just got a batch of new requirements. Let's also say that it has a fairly simple re...
-
Bước 1 . Sử dụng ảnh rocket.psd để import vào trong dự án Flash của bạn. Xây dựng 2 layer để chứa tên lửa và phần nhiên liệu bị đốt cháy. Bư...
-
Về cơ bản, screensaver là một tập tin có khả năng tự thực thi (executable). Do đó, nó có thể phát triển bằng hầu hết các ngôn ngữ lập trình....
-
Đầu năm đầu tháng khai xuân một bài. Chúc mọi người một năm mới đầy sức khoẻ, may mắn, hạnh phúc. Mình về tết cũng rảnh đôi chút, sửa lại ch...
-
[FD's BlOg] - Adnet là một hệ thống quảng cáo trực tuyến trên nền tảng mạng Internet mà công cụ chính là các Website & Blog. Adnet ...
-
Là công cụ dùng để soạn thảo nội dung văn bản trong Flash. Hình 43 – Công cụ Text - Text ...
-
I'd like to make a post about something that I think is one of the least utilized aspects of C#: custom collection initializers. Impleme...
No comments:
Post a Comment