Correcting Mistakes...using Standard C++

Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Feb 2009
Posts: 35
Reputation: Nikhar is an unknown quantity at this point 
Solved Threads: 0
Nikhar Nikhar is offline Offline
Light Poster

Correcting Mistakes...using Standard C++

 
0
  #1
Jun 23rd, 2009
Well, I posted a few problems here on daniweb and thank god that I did so. What I had been using till now was "rusted, naff,useless" code. But after today, I am more accustomed to what the new c++ is.

Well, I am 16 years old and am studying in standard 10+2.

The problem is the way we are taught in school. In school, we still use
#include<iostream.h>,#include<conio.h>,getch(),clrscsr()...etc.etc....


Considering the fact that I have already had 1.5 years of study in c++(using the old ways), you may guess my current condition.
I referred to Siddhants guide and found it quite useful. Thanks.

Well, coming to the point on what I want...

If anyone could help me and provide me with link to the better tutorials on Standard and modern C++, I would be highly grateful.

Well, I don't know how to use vectors. So,a guide on vectors would be useful.

Also, a list of modern header files would be extremely useful. From my information, conio.h is not in use anymore. So, how can I use stuff like cout, cin, etc.

What are namespaces?

And a list of things and functions which are outdated now, and the new ones to replace them would be great.

Thanks a ton in advance. Any help would be greatly appreciated.
Reply With Quote Quick reply to this message  
Join Date: Jan 2007
Posts: 25
Reputation: Grigor is an unknown quantity at this point 
Solved Threads: 3
Grigor's Avatar
Grigor Grigor is offline Offline
Light Poster

Re: Correcting Mistakes...using Standard C++

 
0
  #2
Jun 23rd, 2009
http://www.mindview.net/Books/TICPP/...ngInCPP2e.html

Direct link to Volume 1

Direct link to Volume 2

These books should be perfect for you. Volume 1 may cover some topics you already know, but it also covers namespaces, templates, and polymorphism. Volume 2 teaches you the Standard C++ Library and the Standard Template Library.

Reference to the C++ Standard headers - http://www.cplusplus.com/reference/
Last edited by Grigor; Jun 23rd, 2009 at 10:59 am.
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 630
Reputation: daviddoria is a jewel in the rough daviddoria is a jewel in the rough daviddoria is a jewel in the rough 
Solved Threads: 46
daviddoria daviddoria is offline Offline
Practically a Master Poster

Re: Correcting Mistakes...using Standard C++

 
0
  #3
Jun 23rd, 2009
  1. #include <iostream>
is where you will find cout, etc.

namespaces are ways to group functions - for example, the cout, etc you are looking for are in the std namespace, so you have to call them like this:
  1. #include <iostream>
  2.  
  3. int main()
  4. {
  5. std::cout << "something" << std::endl;
  6. return 0;
  7. }

Other useful things in the std namespace:
  1. #include <vector>
  2. #include <string>
  3. etc.

good luck

dave
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 1,968
Reputation: tux4life has a reputation beyond repute tux4life has a reputation beyond repute tux4life has a reputation beyond repute tux4life has a reputation beyond repute tux4life has a reputation beyond repute tux4life has a reputation beyond repute tux4life has a reputation beyond repute tux4life has a reputation beyond repute tux4life has a reputation beyond repute tux4life has a reputation beyond repute tux4life has a reputation beyond repute 
Solved Threads: 214
tux4life's Avatar
tux4life tux4life is offline Offline
Posting Virtuoso

Re: Correcting Mistakes...using Standard C++

 
0
  #4
Jun 23rd, 2009
This ebook is the most suitable for you I think, superb explanations, cool code examples, answers to most of your C++ questions...
"Never argue with idiots, they just drag you down to their level and then beat you with experience."
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 681
Reputation: Tom Gunn has much to be proud of Tom Gunn has much to be proud of Tom Gunn has much to be proud of Tom Gunn has much to be proud of Tom Gunn has much to be proud of Tom Gunn has much to be proud of Tom Gunn has much to be proud of Tom Gunn has much to be proud of Tom Gunn has much to be proud of Tom Gunn has much to be proud of 
Solved Threads: 132
Tom Gunn's Avatar
Tom Gunn Tom Gunn is offline Offline
Practically a Master Poster

Re: Correcting Mistakes...using Standard C++

 
-2
  #5
Jun 23rd, 2009
What I had been using till now was "rusted, naff,useless" code.
There's nothing wrong with writing code on an old compiler. You gotta do what you gotta do, and what you gotta do isn't ever ideal. It's easy for some armchair critic to complain, but you're the one who has to get the job done by any means necessary.

If anyone could help me and provide me with link to the better tutorials on Standard and modern C++, I would be highly grateful.
These two books will help.

From my information, conio.h is not in use anymore.
conio.h is used a lot. There's not a standard way to do the stuff conio.h does either. Clearing the screen, changing text color, getting a key press without typing Enter, standard C++ doesn't do any of it the same way, and the standard analogs are not as useful. If you need something from conio.h, no matter how you go about it you'll get yelled at by somebody that it isn't portable, and your code is wrong, and standard C++ is GOD, and you're stupid for not writing code exactly like them, and whatever else those guys whine about.

I say you should learn how to use everything, portable or not, standard or not, and then choose the best of them for what you need to do. Being standard and portable is a great goal, but to get anything substantial done you have to compromise somewhere.

What are namespaces?
Ok, you write a library that has a function called DoStuff(). You have a friend who wrote another library that has a function called DoStuff(). You want to use both libraries. What do you do?

The easiest thing is to change the name of DoStuff() in your library to something like MyDoStuff(). Now there's no conflict between the two functions. Namespaces do the same thing without changing the name of the function. They add another piece to the puzzle of choosing which name to use.

If you and your friend both use namespaces, there won't be any conflict to start with:
  1. namespace Friend
  2. {
  3. void DoStuff();
  4. }
  5.  
  6. namespace Me
  7. {
  8. void DoStuff();
  9. }
The full name of your friend's DoStuff() is Friend::DoStuff() . Yours is Me::DoStuff() . Both names are unique because the namespace part of the name is different.

That's it! Namespaces are a way to avoid name conflicts.
-Tommy (For Great Justice!) Gunn
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 793
Reputation: siddhant3s has much to be proud of siddhant3s has much to be proud of siddhant3s has much to be proud of siddhant3s has much to be proud of siddhant3s has much to be proud of siddhant3s has much to be proud of siddhant3s has much to be proud of siddhant3s has much to be proud of siddhant3s has much to be proud of siddhant3s has much to be proud of 
Solved Threads: 135
siddhant3s's Avatar
siddhant3s siddhant3s is offline Offline
Master Poster

Re: Correcting Mistakes...using Standard C++

 
0
  #6
Jun 23rd, 2009
Well, I know that guide was not exhaustive. It was not a reference material, it was just a guide.
I clearly mentioned that you will have to search for more information about specific topic on the web.
Learn to use a search engine well. There is a sticky thread about C++ books.
My personal favorite are Accelerated C++ ( non-free ) and Thinking in C++ ( a free book by Bruce Eckels)

Though I myself prefer books, you may want to start with a tutorial. But do what ever, stay away from short guides like Sams " Teach yourself C++ in X days" <-- stay away from such guides.

Also read How to Ask Question the Smart Way the link is here.
Last edited by siddhant3s; Jun 23rd, 2009 at 11:08 am.
Siddhant Sanyam
(Not posting much)
Migrate to Standard C++ :When to tell your C++ Code is Non-Standard.
Please Read before posting: How To Ask Questions The Smart Way
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 35
Reputation: Nikhar is an unknown quantity at this point 
Solved Threads: 0
Nikhar Nikhar is offline Offline
Light Poster

Re: Correcting Mistakes...using Standard C++

 
0
  #7
Jun 23rd, 2009
Thanks Grigor. Would check the books soon.

Thanks daviddoria for your advice.

Thanks tux4life. Would check the books soon.

Thanks Tom Gunn for your advice. Would check the book.

Thanks Siddhanth for your advice.

More advices would be appreciated.
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 21
Reputation: Topi Ojala is an unknown quantity at this point 
Solved Threads: 5
Topi Ojala's Avatar
Topi Ojala Topi Ojala is offline Offline
Newbie Poster

Re: Correcting Mistakes...using Standard C++

 
0
  #8
Jun 23rd, 2009
Someone linked these YouTube video tutorials, I think you should check them out.

http://www.youtube.com/watch?v=Jud497WjF-E&feature=fvst
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 1,607
Reputation: jephthah has much to be proud of jephthah has much to be proud of jephthah has much to be proud of jephthah has much to be proud of jephthah has much to be proud of jephthah has much to be proud of jephthah has much to be proud of jephthah has much to be proud of 
Solved Threads: 120
jephthah's Avatar
jephthah jephthah is offline Offline
Posting Virtuoso

Re: Correcting Mistakes...using Standard C++

 
0
  #9
Jun 23rd, 2009
The problem is the way we are taught in school. In school, we still use
#include<iostream.h>,#include<conio.h>,getch(),clrscsr()...etc.etc....
I say that you should avoid the use of old, non-standard libraries like "conio.h" unless you are explicitly instructed -- required -- to do so.

anyone can quickly learn to use any library function that one may given in the course of their work. But you will only be hurting yourself if you learn to rely on those non-portable functions, and then one day find all your code is broken when you try to port it to another environment.

also, when you come to ask questions on a standard-C forum like this one or any of the other major forums, you will lose the assistance of people who do not, can not, or will not use non-portable libraries such as conio.

ultimately it's your choice. personally, my choice is that i just don't even bother trying to compile anyone's code who uses non-standard libraries. I simply don't care to include those libraries on my work or home machines, and therefore i don't spend any time trying to debug examples those people might post.
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 5,850
Reputation: Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute 
Solved Threads: 749
Team Colleague
Salem's Avatar
Salem Salem is offline Offline
Void main'ers are DOOMed

Re: Correcting Mistakes...using Standard C++

 
0
  #10
Jun 23rd, 2009
> This ebook is the most suitable for you I think, superb explanations, cool code examples, answers to most of your C++ questions...
And patently wrong statement even in the first paragraph!
"Simply stated, to be a professional programmer implies competency in C++."

So all the C, Perl, Java, Python, Fortran, COBOL programmers in the world are amateur hacks?
Rubbish!

I wonder how "chummy" it gets with the Microsoft compiler, since it is hosted on their site?
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC