Learning c++ text makes my brain die

In summary: Yes, using cin.ignore(); and cin.get(); is a good practice. They are called "cin" because they are used to read input from the keyboard.
  • #1
Rhine720
88
0
I've been working on learning c++ pre-emptive to going to college. I've found that I've come to learn it really well off of youtube videos. Unfortunatly there is no youtube series spanning the variety of fields in c++ that i need to learn.

I read too fast and find myself reading right into things that i have no idea how they got there. I quickly find myself lost and confused. I've been reading c++ for dummies. For the most part I've gained some useful knowledge.

Anyway, Does anyone know of any decent c++ video lessons/tutorials that covers things such as function arguments,arrarys..ectect.?

Thanks!
 
Technology news on Phys.org
  • #2
I doubt I can give you anything on youtube that you haven't already seen. But you can also check MIT OCW or UC Berkeley webcast for C++ videos.

I would recommend C++ Primer Plus by Stephen Prata. Its an excellent read.
 
  • #3
Other than ranger recommendations, I would suggest you not to read the book but solve simple problems (developing simple programs in c++ starting from hello world) and refer to the book as you go. If you cannot find good simple problems, refer to the c++ book for the problems.
 
  • #4
Just go to the library and get a nice, big, thick book with a name like "the C++ bible for masochists".

Then slowly read through the book. Whenever they introduce a new idea, write some code and compile. It can do anything. Read actively.

When they introduce variables, write a program that defines one of each kind of variable. Assign the variables values. Initialize them.

When you get to arrays, define some arrays. Initialize them. Set elements.

See what I'm saying? Active participation as you're reading... not just reading for ideas... will make it so much easier. Get a good IDE for doing this. I can recommend Microsoft Visual Studio C++ Express Edition.
 
  • #5
Hey Man.

I know that feeling of reading to fast. I'ts because of **** tutorials that it happens.
Anyway I don't know of any good video lessons but I used this one from this Herbert dude http://msdn.microsoft.com/en-us/beginner/cc305129.aspx its great.
One piece of advise download the pdf one for good ofline reference.

Happy coding dude!
 
  • #6
Rhine720 said:
I've been working on learning c++ pre-emptive to going to college. I've found that I've come to learn it really well off of youtube videos. Unfortunatly there is no youtube series spanning the variety of fields in c++ that i need to learn.

I read too fast and find myself reading right into things that i have no idea how they got there. I quickly find myself lost and confused. I've been reading c++ for dummies. For the most part I've gained some useful knowledge.

Anyway, Does anyone know of any decent c++ video lessons/tutorials that covers things such as function arguments,arrarys..ectect.?

Thanks!

Rhine, I found these lectures from Stanford to be pretty good:

Programming Abstractions (CS106B)
http://www.youtube.com/view_play_list?p=FE6E58F856038C69

Programming Paradigms (CS107)
http://www.youtube.com/view_play_list?p=9D558D49CA734A02

As for the short (and good) book, I'd definitely recommend "Accelerated C++" -- http://www.acceleratedcpp.com/

Best of luck!
 
  • #7
Thanks to everyone who has replied here. You sources are deffinatly more efficient then what I've been trying to use. I'm going to look at those links MattPD..Thanks!
 
  • #8
I also recommend "Accelerated C++." It uses a "modern" approach to teaching C++ that takes full advantage of the many useful features of the standard library (strings, vectors, etc.), as opposed to many other books which are basically warmed-over C books with the C++-specific stuff spliced in as an afterthought.
 
  • #9
I think it would be a lot more fun--and yes, productive--to start learning Python, which is a powerful, super-useful, fairly "clean" language, does its own garbage collection, a good way to learn the concepts, it's everywhere, and a whole lot less painful to use properly. Best of all, learning it'll go faster, which will help you get the CONCEPTS down, which is the most important thing where you're at, (IMO). Then it'll be a lot easier to translate those concepts over to C++. Ruby would be another great choice. You're going to have to learn a lot of languages anyway, and I recommend those two prior to taking university courses. My personal favorite language is Scheme, but that would probably ruin you from ever wanting to be a C++ programmer. ;)

But not trying to start a contentious language discussion or anything. Just my $0.02.

--Mike from Shreveport
 
  • #10
I'm $0.02 richer then ibcnunabit =]

I am LOVING Accelerated c++

The only thing i dislike is the whole return 0;
and std:: cout

Are those important things I should adopt? Man programmers that I do know usually do a simple cout without stating the function library(std)

Also

After every input i use cin.ignore();

and before I end the program instead of return 0;

I use cin.get();

The reason is mainly because I'm using bloodshed,but is my current practices okay if i were in a professional programming situation?
 
  • #11
To eliminate the need to type the "std::cout", rather add this statement "using namespace std;" in the declaration area somewhere below the include statements.
Then c++ will asume everything is an std.

I think the "return 0;" statement is necessary to clean up the memory but I am not sure.

And what ibcnunabit/Mike from Shreveport said is very correct. Python would have been a better language to learn early(This said asuming that c++ is your first languge). I also had c++ as my first and was quit a strugle but I am now proud to say I am now an extreme pythonist ;-)

Wel then good luck and happy coding 4 u!
 
  • #12
Rhine720 said:
I'm $0.02 richer then ibcnunabit =]

I am LOVING Accelerated c++

The only thing i dislike is the whole return 0;
and std:: cout

Are those important things I should adopt? Man programmers that I do know usually do a simple cout without stating the function library(std)

Also

After every input i use cin.ignore();

and before I end the program instead of return 0;

I use cin.get();

The reason is mainly because I'm using bloodshed,but is my current practices okay if i were in a professional programming situation?

Hi!

Glad you like the book!

Regarding the questions:

(a) int main() { return 0; } -- yes, this is very important; for a few-mins.-long explanation, see e.g. a lecture (by Richard Buckland, UNSW):

// more precisely, just 30:40-37:00, answering to "Can you use void main()?" ;-)

(b) Bloodshed Dev-C++ -- it is a bit outdated -- it has not been under development since 4 years ago; consider switching to something more up-to-date instead, like Code::Blocks:
http://en.wikipedia.org/wiki/Code::Blocks

Instead of playing w/ std::cin.get(), etc., it might be easier just to run the app from the console/shell window :-)

(c) namespaces -- see http://www.devx.com/tips/Tip/12534

Personally, I prefer using declaration (e.g. using std::cout) rather than using directive (like using namespace std;) -- that way, I am always sure which keywords are in the scope and I avoid "polluting" it.

Note, however, that in libraries (header files thereof) which are intended for production use it's best not to use using directives nor declarations at all (or as little as possible), always using fully qualified names instead -- precisely in order to avoid namespace pollution (e.g. you might have two teams of developers working on the modules of a multimedia library, say Video Team and Music Team -- there might be functions like Music::Load() and Video::Load() -- neither of the teams would be very happy if one of the others decided to shove its own "Load" down everyone's throat, right?).

Hence, besides making larger code easier to read (helping one to know where all of the names are coming from), it's a good practice to get used to fully qualified names, as sometimes they're really necessary.

In "Accelerated C++" there is more on that topic -- see 4.3/67 (and later also 9.2).

Hope that helps!
 
Last edited by a moderator:
  • #13
The main function must have integer return type.

However, it is redundant in C++ to actually type "return 0;" this will be assumed if you simply do not write it.

Secondly, EXIT_FAILURE and EXIT_SUCCESS are defined in cstdlib, and these can be more intuitive than having to remember if 0 or 1 is success or failure.
 
  • #14
From the C++ Standard working draft dated 2009-06-22 paragraph 3.6.1:
If control reaches the end of main without encountering a return statement, the effect is that of executing

return 0;
From the C++ Standard working draft dated 2009-06-22 paragraph 6.6.3:
Flowing off the end of a function is equivalent to a return with no value; this results in undefined behavior in a value-returning function
There is no automatic insertion of the return 0 statement or something other magic thing that make it good practice to not have a the return statement in ,,main'' or any other function or method. Because not returning a value from a function that is defined to do so leads to undefined behaviour, except for main.
This is because of the special meaning of main. But even there there is no magic insertion of a statement. The ,,effect'' is the same as if it would be part of the code.

So. Do not forget the return statement in main.
 

Related to Learning c++ text makes my brain die

1. Why is learning C++ text difficult?

Learning C++ text can be difficult because it is a complex programming language with a steep learning curve. It involves understanding complex concepts like memory management, pointers, and object-oriented programming. Additionally, the syntax of C++ can be confusing for beginners.

2. How can I make learning C++ text easier?

There are several ways to make learning C++ text easier. First, start with the basics and gradually build your knowledge. Practice writing code and solving problems regularly. Seek help from online resources, books, or a tutor if needed. Also, try breaking down complex concepts into smaller, more manageable chunks.

3. Is it normal to struggle with C++ text?

Yes, it is normal to struggle with C++ text, especially for beginners. It takes time and effort to fully grasp the language. Don't get discouraged if you encounter challenges along the way. Keep practicing and seeking help, and you will eventually improve.

4. What are the benefits of learning C++ text?

Learning C++ text can lead to a variety of benefits. It is a widely used and versatile language, making it valuable in many industries such as software development, game development, and finance. Additionally, learning C++ can improve your problem-solving skills and make you a more attractive job candidate.

5. How can I stay motivated while learning C++ text?

Staying motivated while learning C++ text can be challenging, but there are a few things you can do. Set specific and achievable goals for yourself. Find a project or problem that interests you and work towards solving it. Surround yourself with a supportive community of other C++ learners. And most importantly, don't forget to take breaks and celebrate your progress along the way.

Similar threads

  • Programming and Computer Science
Replies
8
Views
1K
  • Programming and Computer Science
Replies
6
Views
2K
  • Programming and Computer Science
Replies
11
Views
2K
  • Earth Sciences
Replies
3
Views
452
  • Science and Math Textbooks
Replies
4
Views
1K
Replies
2
Views
965
  • Programming and Computer Science
Replies
10
Views
3K
  • STEM Academic Advising
Replies
14
Views
992
  • Programming and Computer Science
Replies
4
Views
4K
  • Science Fiction and Fantasy Media
2
Replies
44
Views
6K
Back
Top