۰۪۪۫۫●۪۫۰-SolitaryWolf--IT--Let's share together-۰۪۪۫۫●۪۫۰

The place for everyone to discuss anything that you like..specially for Information Technology... Software,Hardware,Program C,C++,C# and more...

image
    Khi vừa chập chững vào con đường lập trình, ta được học ngôn ngữ C. Rồi hướng đối tượng với C++, tiếp đó là C#, Java… Thời gian để nắm bắt một ngôn ngữ lập trình của một sinh viên thực sự quá ngắn, đa số chỉ ở mức độ cơ bản đủ để viết những chương trình demo cho những môn học. Có lẽ vì thời gian quá gấp rút mà chúng ta chỉ lao đầu vào việc sử dụng các chức năng mà ngôn ngữ đó thay vì hiểu từng tính năng đó hoạt động ra sao. Bài viết này sẽ phân tích một số điểm khác biệt trong ngôn ngữ C, C++ , mà rất có thể bạn từng thắc mắc.

1. Sự khác biệt giữa CC++
-   Hầu hết IT trên thế giới đều biết về 2 ngôn ngữ lập trình C, C++. Như chúng ta đã biết, C++ là ngôn ngữ ra đời sau ngôn ngữ C, thực chất nó mở rộng cho ngô ngữ C nhằm tăng cường tính an toàn, cung cấp cho các lập trình viên nhiều lựa chọn hơn, đơn giản hóa lập trình ở mức cao hơn, và cung cấp một cách tiếp cận tốt hơn đối với những chương trình có quy mô lớn.
-   C++ cũng là ngôn ngữ lớn hơn với nhiều tính năng và phức tạp hơn so với C. Giữa C và C++ có rất nhiều khác biệt. Trong khuôn khổ bài viết này, tôi chỉ liệt kê 10 điểm khác biệt chính giữa 2 ngôn ngữ này.
C
                      C++
  • Không phải ngôn ngữ hướng đối tượng.
  • Là một ngôn ngữ hướng đối tượng (gồm 4 khái niệm về hướng đối tượng)
  • Là một ngôn ngữ lập trình thủ tục.
  • Không phải là ngôn ngữ lập trình thủ tục.
  • Chỉ hỗ trợ các structure.
  • Hỗ trợ các lớp và đối tượng.
  • Không có biến tham chiếu, chỉ hỗ trợ con trỏ.
  • Hỗ trợ cả biến tham chiếu và con trỏ.
  • Sử dụng các hàm scanf và printf để nhập xuất.
  • Sử dụng các hàm cin>> và cout<< để nhập xuất.
  • Không thể khai báo hàm trong các structure.
  • Có thể khai báo hàm trong các structure.
  • Được xem là một ngôn ngữ lập trình cấp thấp.
  • Được xem là sự kết hợp giữa ngôn ngữ lập trình cấp thấp và cấp cao.
  • Không hỗ trợ các hàm inline, thay vào đó có thể sử dụng khai báo #define
  • Hỗ trợ các hàm inline.
  • Sử dụng phương pháp tiếp cận từ trên xuống (top-down).
  • Sử dụng phương pháp tiếp cận từ dưới lên  (bottom-up).
  • Là ngôn ngữ lập trình hướng chức năng (function driven).
  • Là ngôn ngữ lập trình hướng đối tượng (Object driven).
-   Dưới đây là danh sách các tính năng được hỗ trợ trong C++ (C không hỗ trợ).
      • Classes
      • Member functions
      • Constructors and destructors
      • Derived classes
      • Virtual functions
      • Abstract classes
      • Access control (public, private, protected)
      • friend functions
      • Pointers to members
      • static members
      • mutable members
      • Operator overloading
      • References
      • Templates
      • Inline functions
      • Default arguments
      • Function overloading
      • Namespaces
      • Exception handling
      • Run-time type identification
      • // comments
      • True const
      • Declarations as statements
      • Automatically typedef’d struct tags
      • Type safe linkage
      • new and delete
      • bool keyword
      • Safer and more robust casting
2. Sự khác biệt giữa endl và ‘n’ trong C++
Trong C++, để kết thúc một dòng sang dòng mới ta có thể sử dụng std::endl hoặc ‘n, nhưng hoạt động của từng cách là khác nhau:
  • std::endl  gửi một ký tự xuống dòng ‘n’ và xóa bộ nhớ đệm đầu ra (output buffer).
  • n’ gửi một ký tự xuống dòng, nhưng không xóa bộ đệm đầu ra.
Nếu bạn sử dụng tính năng debug thì sẽ thấy rõ hơn sự khác biệt này. Lời khuyên là bạn nên sử dụng std::endl sẽ tốt hơn so với ‘n’  vì bộ nhớ đệm được giải phóng hiệu quả hơn.
Ví dụ: sử dụng cả  std::endl và ‘n’ . (Bạn không  thể thấy bước xóa bộ đệm trong quá trình này)
#include <iostream> 
using namespace std;
int main()
{
  cout <<"Testing 1" <<endl;
  cout <<"Testing 2n";
  return 0;
}
Output của chương trình:
 Testing 1
 Testing 2
3. Sự khác biệt giữa printf()cout<<
- printf là một hàm có một số tham biến, tham biến đầu tiên là chuỗi định dạng giải thích việc xử lý các đối số tiếp theo. cout<< là một đối tượng thuộc lớp std::ostream. Cả hai hoàn toàn khác nhau về hình thức, nhưng kết quả đưa ra là giống nhau, dữ liệu đều được gửi đến thiết bị xuất chuẩn.
-   Một vài câu hỏi liên quan:
  • Giữa printf  và cout<<  cái nào hoạt động nhanh hơn?
    -> 
    printf, nhưng khác biệt là rất nhỏ.
  • Giữa printfcout<< cái nào tốt hơn?
    -> Điều đó phụ thuộc vào sở thích cá nhân và những gì cần được thực hiện.
  • Tôi nên sử dụng printf hay cout<< ?
    ->  Bạn nên sử dụng theo cách mà bạn cảm thấy thoải mái nhất. 
-   Chúng ta nên sử dụng iostream của C++ thay vì các hàm của C, bởi vì iostream an toàn hơn cho người dùng tự định nghĩa kiểu.
4. Sự khác biệt giữa NULL, 0, nul
-   NULL là một macro được định nghĩa trong các header chuẩn.
-   0 là hằng số nguyên.
-   là một hằng ký tự.
-   nul là tên của hằng ký tự.
Tất cả những ký hiệu trên không thể hoán đổi cho nhau.
-    NULL được sử dụng cho các con trỏ, chỉ có thể được định nghĩa như ((void *)0), đây là nguyên nhân gây ra các vấn đề với con trỏ.
-   0 có thể được sử dụng ở bất cứ đâu, nó đại diện chung cho  kiểu giá trị ‘không’ và trình biên dịch sẽ sắp xếp mọi thứ.
-  chỉ  được sử dụng  trong các trường hợp nhất định.
-   nul không được định nghĩa trong C hay C++, bạn không nên sử dụng nó, trừ khi bạn định nghĩa nó một cách thích hợp giống như:
#define nul ''
5. Sự khác nhau giữa ‘&’ và ‘*’ trong C++
-   Trong C++, &’ được sử dụng trong việc đa năng hóa (overload) toán tử, lấy địa chỉ của một đối tượng, thực hiện phép toán AND, hoặc thực hiện bất cứ điều gì liên quan đến kiểu người dùng định nghĩa nếu đa năng hóa nó, hoặc tạo một tham chiếu. Trong khuôn khổ bài viết này, tôi sẽ đề cập đến &’ trong trường hợp là tham chiếu (reference).
-   Một tham chiếu là tên thay thế cho một đối tượng, một tên tương tự cùng truy cập đến một vị trí trong bộ nhớ, nhưng có tên khác nhau. Sự khác biệt lớn nhất giữa con trỏ (pointer) và tham chiếu (reference) là một tham chiếu không cần truy cập đến một vùng nhớ.
-   Ví dụ: một tham chiếu
int  i = 1;
int& r = i; // i và r cùng tham chiếu đến một vùng nhớ

r = 2; // i = 2
-   Con trỏ là một biến riêng biệt có chứa địa chỉ bộ nhớ như là giá trị của nó, đó là địa chỉ có thể truy cập đến vùng nhớ. Chức năng của con trỏ tương tự các tham chiếu.
int i = 1;
int *p = &i; // con trỏ p trỏ tới địa chỉ biến i

*p = 2 // i = 2;
-   Sự khác biệt lớn nhất giữa tham chiếu và con trỏ là con trỏ có thể được xử lý như một biến bất kỳ. Do đó ta cũng có thể thực hiện các toán tử trên con trỏ.
char *p = "Test";
p++; // p = "est";

73 comments:

I like the valuable info you provide in your articles.
I will bookmark your weblog and check again here regularly.
I am quite sure I will learn plenty of new stuff right here!
Good luck for the next!

My web page Christian Louboutin Pumps

Good post. I learn something new and challenging on sites I stumbleupon every day.
It will always be helpful to read content from other writers and practice
a little something from other web sites.

Review my homepage: Christian Louboutin Cheap [www.vevocraft.nl]

Awesome post.

Here is my website ... Christian Louboutin

I visited several web pages except the audio feature for audio songs present at this website is actually superb.



Also visit my homepage Louis Vuitton Cheap

It's a shame you don't have a donate button! I'd
most certainly donate to this fantastic blog! I suppose for now
i'll settle for book-marking and adding your RSS feed to my Google account.
I look forward to brand new updates and will talk about this website with my Facebook group.
Talk soon!

Look at my web page - Louboutin Shoes

Very nice post. I just stumbled upon your weblog and wished to say that I've truly
loved surfing around your blog posts. In any case I'll be subscribing to your feed and I
am hoping you write again very soon!

My weblog; Louis Vuitton Outlet

hello there and thank you for your information – I
have definitely picked up anything new from right here.
I did however expertise several technical issues using this
site, as I experienced to reload the website lots of times previous to I could get it to load properly.
I had been wondering if your web host is
OK? Not that I'm complaining, but slow loading instances times will
sometimes affect your placement in google and could damage your high-quality score if advertising and marketing with
Adwords. Anyway I am adding this RSS to my email and can look out for a lot more of your respective exciting content.
Ensure that you update this again very soon.

my web-site :: Christian Louboutin

There's certainly a great deal to learn about this subject.
I like all the points you've made.

Feel free to surf to my web blog GHD NZ

I'm now not certain the place you are getting your info,
however great topic. I must spend a while
learning more or working out more. Thanks for excellent information I was on the lookout for this info for my mission.

Here is my web page: Charlotte Olympia Shoes

Whoa! This blog looks just like my old one! It's on a totally different topic but it has pretty much the
same page layout and design. Wonderful choice of colors!


Also visit my blog - Christian Louboutin Boots

You need to be a part of a contest for one of the greatest websites
on the internet. I'm going to highly recommend this blog!


Feel free to surf to my web-site: Christian Louboutin Shoes

I get pleasure from, result in I discovered exactly what I was taking a look for.

You have ended my four day lengthy hunt! God Bless you man.
Have a nice day. Bye

Also visit my web page Christian Louboutin Sale

hey there and thank you for your information – I have
definitely picked up anything new from right here.
I did however expertise a few technical issues using this website, since I experienced to reload the website many times previous to I could get it
to load properly. I had been wondering if your hosting is OK?
Not that I am complaining, but sluggish loading instances times will sometimes affect your placement
in google and could damage your quality score if ads
and marketing with Adwords. Well I am adding this RSS to
my email and could look out for a lot more of your respective interesting content.
Make sure you update this again soon.

Feel free to surf to my weblog ... Christian Louboutin Boots

Greetings! Very helpful advice in this particular article!

It is the little changes which will make the biggest changes.
Thanks a lot for sharing!

Also visit my web blog ... Dr Dre Beats Tour

Hey there! This is my 1st comment here so I just wanted to give a quick shout out and tell you
I really enjoy reading your blog posts. Can you recommend any other blogs/websites/forums that
cover the same subjects? Many thanks!

My web page Cheap CHI Straighteners

At this time I am going away to do my breakfast,
when having my breakfast coming over again to read further news.


My web page; Louis Vuitton Outlet Store

I absolutely love your blog and find a lot of your post's to be exactly what I'm looking for.
can you offer guest writers to write content to suit your needs?
I wouldn't mind producing a post or elaborating on a number of
the subjects you write with regards to here. Again, awesome site!



My web blog: Christian Louboutin Online

constantly i used to read smaller articles which also clear their motive, and that is also
happening with this piece of writing which I am reading
at this place.

my web blog: CHI Straightener

Yesterday, while I was at work, my sister stole my iPad
and tested to see if it can survive a 40 foot drop, just so she can be a youtube sensation. My apple ipad is now destroyed and she has 83 views.
I know this is totally off topic but I had to share it with someone!


My weblog ... Dr Dre Beats Mixr

Hmm it seems like your site ate my first comment (it was extremely long) so
I guess I'll just sum it up what I wrote and
say, I'm thoroughly enjoying your blog. I as well am an aspiring blog blogger but I'm still new to everything.
Do you have any recommendations for novice blog writers?
I'd genuinely appreciate it.

Feel free to visit my web blog Charlotte Olympia Heels

Hi friends, pleasant paragraph and pleasant arguments
commented at this place, I am actually enjoying by these.


my homepage :: Replica Christian Louboutin

Hi friends, pleasant paragraph and pleasant arguments commented at this place, I am
actually enjoying by these.

My page - Replica Christian Louboutin

I got this site from my buddy who informed me concerning this
web page and at the moment this time I am browsing this web site and reading
very informative content at this time.

Also visit my page; Christian Louboutin USA

I like the valuable information you provide in your articles.

I will bookmark your blog and check again here frequently.

I am quite certain I'll learn a lot of new stuff right here!
Good luck for the next!

Also visit my weblog Beats By Dr Dre

I like the valuable information you provide in your articles.
I will bookmark your blog and check again here frequently.
I am quite certain I'll learn a lot of new stuff right here!
Good luck for the next!

My website; Beats By Dr Dre

I was recommended this blog via my cousin. I'm not positive whether this submit is written via him as no one else realize such distinct
approximately my trouble. You're amazing! Thank you!

Also visit my weblog; Christian Louboutin Cheap

I was recommended this blog via my cousin. I'm not positive whether this submit is written via him as no one else realize such distinct approximately my
trouble. You're amazing! Thank you!

Here is my homepage - Christian Louboutin Cheap

Hey very nice blog!

Feel free to visit my blog Beats By Dre Cheap

Hi there friends, its impressive article regarding educationand fully explained, keep it up all
the time.

Here is my webpage :: Beats By Dre UK

This piece of writing gives clear idea for the new people of blogging, that
actually how to do blogging.

my website - Beats By Dre

you are truly a good webmaster. The website loading pace is incredible.

It seems that you are doing any distinctive trick.
Also, The contents are masterwork. you have performed a excellent job
in this topic!

my web page ... Louis Vuitton Handbags

Write more, thats all I have to say. Literally, it seems as
though you relied on the video to make your point. You clearly
know what youre talking about, why waste your intelligence on just
posting videos to your blog when you could be giving us something informative to read?


My web page ... GHD Stockists NZ

Hello, i believe that i noticed you visited my site
so i got here to return the favor?.I'm trying to to find issues to improve my website!I assume its good enough
to use some of your ideas!!

My website; Beats By Dre Cheap

I am sure this piece of writing has touched all the internet people,
its really really pleasant post on building up new web site.



My homepage :: CHI Hair Straighteners

Nice post. I learn something new and challenging on sites I
stumbleupon on a daily basis. It's always exciting to read content from other authors and
use something from their web sites.

my web-site ... Hair Straightener

We're a group of volunteers and opening a new scheme in our community.
Your website offered us with valuable information to
work on. You've done a formidable job and our whole community will be thankful to you.


Feel free to surf to my page Christian Louboutin

Greate post. Keep writing such kind of info on your page.

Im really impressed by it.
Hi there, You've done an excellent job. I'll definitely digg
it and in my view recommend to my friends. I am sure they'll
be benefited from this site.

Also visit my homepage; Beats Monster

Keep on working, great job!

Look at my blog post ... Beats By Dre Cheap

Appreciating the hard work you put into your site and in depth information you provide.
It's great to come across a blog every once in a while that isn't
the same unwanted rehashed information. Fantastic read!
I've bookmarked your site and I'm adding your RSS feeds to my Google account.



Take a look at my webpage; Christian Louboutin London

I blog quite often and I really thank you for your information. This article
has truly peaked my interest. I will take a note of your site and
keep checking for new information about once per week. I opted in for your RSS feed as
well.

Here is my web blog: Cheap Louis Vuitton

Hello to all, how is everything, I think every one is getting more from this
website, and your views are good in support of new people.


Feel free to surf to my homepage; Christian Louboutin Sale

Hello there, There's no doubt that your site might be having browser compatibility issues.
Whenever I take a look at your website in Safari,
it looks fine however, if opening in I.E., it has some overlapping issues.
I merely wanted to provide you with a quick heads
up! Other than that, great website!

Here is my homepage: Beats Headphones

Hello There. I discovered your weblog the usage of msn. This is a really smartly
written article. I will be sure to bookmark it and come back to learn more
of your helpful info. Thanks for the post.
I'll definitely return.

Here is my web page - Dr Dre Headphones

Great article, just what I was looking for.

Feel free to surf to my blog - Beats Headphones

The other day, while I was at work, my cousin stole my iphone and
tested to see if it can survive a forty foot drop, just so she can be a
youtube sensation. My iPad is now broken and she has 83 views.
I know this is completely off topic but I had to share it with someone!


Here is my blog post; Louis Vuitton Online

Hi there, I believe your website may be having web
browser compatibility issues. When I take a
look at your web site in Safari, it looks fine however when opening in I.E., it has some overlapping issues.
I just wanted to give you a quick heads up! Other than that, fantastic website!


Feel free to visit my blog: Beats By Dre Cheap

Wonderful blog! I found it while searching on Yahoo News.
Do you have any tips on how to get listed in Yahoo News?
I've been trying for a while but I never seem to get there!
Thanks

Also visit my web blog :: Christian Louboutin UK

Everything is very open with a very clear clarification of
the issues. It was definitely informative.
Your site is very helpful. Thanks for sharing!


Also visit my blog ... Christian Louboutin

It's really a cool and helpful piece of information. I'm glad that you just shared this useful info
with us. Please stay us up to date like this. Thank you for sharing.


Feel free to surf to my weblog; Louboutin Shoes

It's perfect time to make a few plans for the long run and it is time to be
happy. I've read this submit and if I may just I want to counsel you some attention-grabbing issues or advice.
Maybe you could write next articles referring to this article.
I wish to read even more issues approximately it!


My blog post :: Hair Straightener

I was recommended this web site by my cousin. I am not sure whether this post is written by him as nobody else
know such detailed about my difficulty. You're wonderful!

Thanks!

Also visit my web page; Dr Dre Headphones

Its like you read my mind! You seem to know a lot about this, like
you wrote the book in it or something. I
think that you could do with a few pics to drive the message home
a bit, but other than that, this is excellent blog.
An excellent read. I will definitely be back.

Feel free to surf to my web-site ... Replica Louis Vuitton

Ahaa, its fastidious conversation regarding this piece of
writing at this place at this web site, I have
read all that, so now me also commenting here.

Feel free to visit my webpage ... Chi flat iron

Fabulous, what a blog it is! This blog gives
useful information to us, keep it up.

Feel free to surf to my blog post :: Dr Dre Beats Studio

My family members all the time say that I am killing my time here at web,
except I know I am getting familiarity all the time by reading thes nice articles or reviews.


Also visit my web site Christian Louboutin Shoes

Hello There. I found your blog the usage of msn. This is a very smartly
written article. I'll be sure to bookmark it and
return to learn extra of your useful info. Thank you for the post.
I will definitely comeback.

Feel free to surf to my homepage New Balance Shoes

Heya! I'm at work surfing around your blog from my new iphone 3gs!
Just wanted to say I love reading your blog and look forward to all your posts!
Keep up the excellent work!

Also visit my weblog ... Christian Louboutin Discount

I really like what you guys are usually up too.

This kind of clever work and reporting! Keep up the fantastic
works guys I've incorporated you guys to my own blogroll.


Feel free to surf to my web-site; Christian Louboutin Outlet

Just desire to say your article is as astonishing.

The clarity in your post is just excellent and i can assume you are an expert on this
subject. Fine with your permission let me to grab your RSS feed to keep up to date with forthcoming post.

Thanks a million and please carry on the rewarding work.


Look at my site ... Cheap New Balance

This is very interesting, You're a very skilled blogger. I've joined your feed and look forward
to seeking more of your excellent post. Also, I have shared your website in my
social networks!

Feel free to visit my website :: Christian Louboutin Sale

Asking questions are truly fastidious thing
if you are not understanding something entirely,
except this article offers good understanding yet.

Here is my page; Beats By Dr. Dre

I was suggested this blog by my cousin. I am not sure whether this post is written by him as
no one else know such detailed about my trouble. You're wonderful!

Thanks!

Feel free to visit my web site - Dr Dre Headphones

Nice post. I was checking constantly this blog
and I am impressed! Extremely helpful info specially the last part :
) I care for such info much. I was seeking this particular information for a long time.

Thank you and good luck.

Feel free to visit my blog ... Louis Vuitton Outlet Store

Very descriptive post, I loved that bit. Will there be a part 2?


My web page New Balance Store

Hello there, I discovered your website by means of Google whilst looking for a comparable topic, your site got here up, it seems to be great.
I have bookmarked it in my google bookmarks.
Hello there, simply became alert to your weblog via Google, and located that it's truly informative.
I'm going to be careful for brussels. I will be grateful in the event you proceed
this in future. A lot of other folks might be benefited out of your writing.
Cheers!

Feel free to surf to my weblog ... New Balance Sale

Keep this going please, great job!

Look at my site - New Balance Shoes

Thank you for the good writeup. It in fact was a amusement account
it. Look advanced to more added agreeable from you!
By the way, how could we communicate?

Feel free to surf to my website; Running Shoes

Excellent pieces. Keep writing such kind of information on your page.
Im really impressed by your blog.
Hi there, You have done an incredible job.
I'll certainly digg it and in my view recommend to my friends.
I'm confident they'll be benefited from this website.


Take a look at my blog Dr Dre Beats Mixr [www.alom.ru]

I am in fact delighted to glance at this weblog posts which contains lots of valuable
information, thanks for providing these information.

Here is my blog post: Cheap Dr Dre Beats

This design is steller! You definitely know how to keep a reader entertained.
Between your wit and your videos, I was almost moved to start my own blog (well, almost...HaHa!) Fantastic job.
I really loved what you had to say, and more than that, how you presented it.
Too cool!

Here is my page - Louboutin Shoes

Thanks for the marvelous posting! I really enjoyed reading it, you could
be a great author.I will always bookmark your blog and will
often come back in the foreseeable future. I want to encourage you continue your great
writing, have a nice afternoon!

Also visit my page :: Christian Louboutin Sale

Excellent article! We will be linking to this particularly great content on our site.
Keep up the good writing.

Also visit my webpage - Beats By Dre

It's perfect time to make some plans for the future and it
is time to be happy. I've read this post and if I could I wish to suggest you few interesting things or advice.
Maybe you could write next articles referring
to this article. I desire to read more things about it!


Also visit my website - Louis Vuitton Bags

Post a Comment

Followers!

About this blog

When you're sad and have sorrow just visit me...^^

Total Pageviews

Most Viewer