943,735 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Marked Solved
  • Views: 735
  • C++ RSS
You are currently viewing page 1 of this multi-page discussion thread
Jun 23rd, 2009
0

Correcting Mistakes...using Standard C++

Expand Post »
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.
Similar Threads
Reputation Points: 29
Solved Threads: 0
Junior Poster in Training
Nikhar is offline Offline
74 posts
since Feb 2009
Jun 23rd, 2009
0

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

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.
Reputation Points: 27
Solved Threads: 3
Light Poster
Grigor is offline Offline
26 posts
since Jan 2007
Jun 23rd, 2009
0

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

C++ Syntax (Toggle Plain Text)
  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:
C++ Syntax (Toggle Plain Text)
  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:
C++ Syntax (Toggle Plain Text)
  1. #include <vector>
  2. #include <string>
  3. etc.

good luck

dave
Featured Poster
Reputation Points: 437
Solved Threads: 204
Posting Virtuoso
daviddoria is offline Offline
1,968 posts
since Feb 2008
Jun 23rd, 2009
0

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

This ebook is the most suitable for you I think, superb explanations, cool code examples, answers to most of your C++ questions...
Reputation Points: 2125
Solved Threads: 243
Postaholic
tux4life is offline Offline
2,105 posts
since Feb 2009
Jun 23rd, 2009
-2

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

Quote ...
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.

Quote ...
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.

Quote ...
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.

Quote ...
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:
c++ Syntax (Toggle Plain Text)
  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.
Reputation Points: 1446
Solved Threads: 135
Practically a Master Poster
Tom Gunn is offline Offline
681 posts
since Jun 2009
Jun 23rd, 2009
0

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

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.
Reputation Points: 1486
Solved Threads: 140
Practically a Posting Shark
siddhant3s is offline Offline
816 posts
since Oct 2007
Jun 23rd, 2009
0

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

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.
Reputation Points: 29
Solved Threads: 0
Junior Poster in Training
Nikhar is offline Offline
74 posts
since Feb 2009
Jun 23rd, 2009
0

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

Someone linked these YouTube video tutorials, I think you should check them out.

http://www.youtube.com/watch?v=Jud497WjF-E&feature=fvst
Reputation Points: 13
Solved Threads: 18
Junior Poster in Training
Topi Ojala is offline Offline
60 posts
since May 2009
Jun 23rd, 2009
0

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

Quote ...
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.
Reputation Points: 2143
Solved Threads: 178
Posting Maven
jephthah is offline Offline
2,567 posts
since Feb 2008
Jun 23rd, 2009
0

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

> 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?
Team Colleague
Reputation Points: 5862
Solved Threads: 950
Posting Sage
Salem is offline Offline
7,164 posts
since Dec 2005

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC