Notes and adventures after March 17th!!! ☺☻

Hello everyone! Once again I got three emails that made me smile!!! I have two more followers and I got a like on yesterday’s post! Hooray! Everyone’s so interested in my Comp3010 adventures! Thanks for your support everyone! I’ll try my best to get an A on this course and to continue to write posts!☺♥☻

ImageImage

Image

So now I’ll start with the notes from my second notebook. All the first comp pages are full of pseudo code and code of that EVIL LAB 5!!!!!!!!!!!! I will show you some of it.

ImageImageImageImage

Something important that I learned while doing lab 5 is that if it’s a void function you can’t assign it to other variables because it doesn’t return a value. Lol. Yeah… I was trying to do that for one of the problems… Teehee…

So in one of our classes we talked about debugging but I promise you debugging is NOT MY FORTE!!!!!!! That STUPID debugger! It’s so confusing… But I actually used it a lot to see if I could figure out the mistake on my loop in problem 5 so we became frienemies. However I still have trouble getting its essence….. Blaaaaaaaugh….. But check this out, something weirderer happened. The prof told us that one way of debugging was this:

Int main(int argc, char **argv){

}

W0W! I have no idea how to use that and there were a lot of things that I didn’t understand when he was explaining it but I admit that day my head was up in the clouds so I felt super ashamed and didn’t feel comfortable asking anything else. But because I did ask things the prof ended up telling me to look these two things up: unit testing and test driven development.

I’ll do it right after I tell you that I just remembered what all that command stuff above is. Well it’s this REALLY interesting thing where when you’re going to run your program you add some words and it runs some tests. The prof ran all those tests and all for in class but because I’m like that I didn’t get much of what was being done…….. I feel terrible now… Anyway if you want to make it work you have to let the compiler(?) know how many words will be added. But anyway I have this other thing written on my notebook:

Int main(int argc, char **argv){

If (argc >=2)

}

I think this is how it is done but I’m not sure. MUST ask about it later….

O.k so unit testing, I just looked it up on C++ reference we have but on the search bar so what I’m going to say was taken from a forum which means it could be right or wrong! Acc to what I just read unit testing(which makes sense) is when you test each function as a standalone function. Well that makes sense and that’s what I was doing every time I did a driver program. So I guess when you do a driver program you’re doing unit testing. It all makes sense now~

Test driven development is a cycle where you right a little bit of code test it and so on… Didn’t get it very well but I get the feeling it’s similar to unit testing.

O.k! Now we start w/ chapter 6, Mr. Complicated. Ugh…… Things are about to get UGLY mind boggling. O.k Let’s begin by defining a class. According to my notes, classes are subsets of types. In other words classes are types. And every object is a variable. But a variable is an object if its type is a class… I feel like I need a flow diagram, eesh…… But anyway according to what I read in the book an object is a special kind of variable that has it’s own functions attached to it. Cool!

By now I’ve learned that a stream is a flow of data and its value is a connection to an existing file. So there are all kinds of stream and it can be input stream(comes from keyboard or file) or output stream(goes to screen or file).

So anyway I/O stands for input/output and guess what? Cin anf cout are STREAMS! That’s why we use the include directive <iostream>.

I have here that a stream object is a description of the file to which it is connected to, hmmm……

We also learned about a new include directive, <fstream> we use this one when we want to use streams that connect our program to external files. If you want to do that then you need to declare your streams just like w/ normal vars. But these streams will be type ifstream, ofstream, istream, ostream, etc…

Image

So sometimes instead of returning you’ll want to exit. So instead of typing return(0) we type exit(any other number different from zero). For example we use it when we want to test whether our file failed to open!

So we learned a lot about connecting files for output and input and what not and then we moved on to learning about width! Width was a fun topic. It’s basically for leaving spaces and aligning. For example you can do this:

Out_stream.width(4) if you have 3 numbers that you want to output they will be one space to the right… something like that… But guess what if we have 5 # the entire output will be printed and you basically accomplished nothing with width.

Remember how we would use .setf for the decimal pt and all that? Well guess what?! There’s unsetf too!!!!!! OOH! And guess what I learned that I found super interesting?! If you want to output a random number that was part of nothing just random output because it’s a number it doesn’t need quotations. I know quotations are only for text but it’s just that I thought random numbers counted as text too. But they don’t.

We also learned about setfill but my mind was wondering so I ever really got what it was for so I’ll ask the prof later. But in the mean time I found this at the reference:

/*unspecified*/ setfill (char_type c);

Set fill character

Sets c as the stream’s fill character.

Behaves as if member fill were called with c as argument on the stream on which it is inserted as a manipulator (it can be inserted on output streams).

This manipulator is declared in header <iomanip>.

Now I’ll talk about characteristics of things:

Image

Setf’s are sticky in the sense that it has effect until you unset it or do something that overwrites it.

Width is nonsticky

IMPORTANT! Streams are always passed by reference! But why? Well I’m not sure but the prof said that would be a test question so I better hurry up and figure it out. I’ll tell you what I think the answer is.

Well first of all, if we want to pass something by reference or by value it must mean we’re using it in a function, right? So if I’m using a stream parameter it has to be called by reference because a stream’s value is a connection to a file and its contents could change and we need them to complete running the program. Call-by-reference parameters allow us to change the variable used in the function call. Not only that, but a stream is a variable which is what an argument for call by reference must be. Anyway when we pass a stream we’re doing something that we’ll get us either output or input and at least to obtain input values we need to change the variable so there we go. I wonder how much I would get w/ this answer?? Gee…..

SO um now we go on to get functions which I don’t get at all the only thing I know is that they don’t skip over whitespace but even so eeeh? So the extraction operator actually does skip and junk, yeah. Blah… I feel like I’ll FAIL! DAAAAAMN IT!!!!!!!!!!!!! Tears++ lol!

 

Oooh! Good news! I just got another email with another follower: Ta-da!!!

 

Image

 

Anyway this is it for today! Must go do lab 6 and practice test! ☺♥☻. BYE!!!!!!

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s