Lecture 2 Zoom Q&A


Q: Good Morning, When will the assignement 1 will distributed?

A1: Assignment 1 will be released on Saturday and will be due the following Friday


Q: I wasn't here on Monday - besides completing assignment 0 is there anything else I need to do/know?

A1: Make sure to sign up for a section – signups open tomorrow at 5pm.


Q: We’re muted by default right?

A1: live answered


Q: How do you reccomend that we take notes for this course? For instance, in a document or in a program file?

A1: Persona preference? Whatever works best for you. I personally like writing on paper, as this act causes the info to register more in my brain more than typing. YMMV

A2: Whatever works best for you! A program file might be helpful but keep in mind not all notes will be code based


Q: After assignmen 0, do we have to use QtCreator to code our project or can you just use gcc/gdb/make in the commandline? Obviously if we go to office hours QtCreator is expected, I'm just asking for my own personal use.

A1: The CS106 projects are all configured to build within Qt (using its build system, qmake). Underneath it is using make, gcc/clang, gdb/lldb, etc) but you won’t directly interact with those tools


Q: How do you create and set up a new project file in Qt Creator?

A1: You can just copy the .pro file from any CS106 project into a folder of .cpp files and voila, you have a new project.

A2: project such as Welcome, Assign0, lecture example, etc. There is also a blank sample project on web at cs106b.stanford.edu/qt/SampleProject.zip


Q: I submitted Assignment 0 twice :(, which one would be considered?

A1: The most recent one


Q: So are all these libraries that we're using? And are these constants that we

A1: Yes, you will eventually use these same libraries


Q: Is it possible to include c++ scripts that we create in other c++ files through this #include statement?

A1: Yes, #include is used to import code /interface from other files into the current file


Q: So are all these libraries that we're using? And are these constants that we will apply to every program?

A1: Yes


Q: How can we check whether we’ve properly submitted assignment 0? I don’t think I received a copy of my form.

A1: We have your submission.


Q: if you #include your own .h file, where does it have to be for it to be able to be read by all-examples.cpp?

A1: Easiest is to have both files in same folder. There is also a more complex way to control the search path


Q: Do you always have to build your program before running it?

A1: If you don’t build then QT will automatically build for you when you try to run


Q: So we would reference the actual .cpp file or the compiled code? Like if I created the C++ file and wanted to use it in another C++ file that I was developing?

A1: You generally #include a header file(name ends in .h) which doesn’t contain code, just declarations. This makes the features visible to the other file. The code is in a file named .cpp that is companion to the .h


Q: Do we not need a namespace for the Stanford library?

A1: namespace isn’t necessary, it just makes code cleaner

A2: No, the features from the Stanford library are in the global namesapce


Q: Is it possible to use the curly brackets in the following way ot it’s a bad style? int main() { … return 0; }

A1: Either way is fine, as long as you stay consistent through all your code.


Q: Does main always need to return something?

A1: Yes, in C++

A2: Yes, it has to return an int (C++ rules)


Q: are java methods the same as c++ functions?

A1: Basically, yes


Q: '@Julie, when you say global namespace, do you mean std or something already integrated into Qt Creator?

A1: Global namespace is the catch-all place for C++ functions to be defined, not specific to Qt, this is a C++ language feature


Q: how is int main different from int a? is main an integer function?

A1: Main is a function that returns an int. int a is a variable of type int


Q: do .h header files have to be in the same directory as the project or the cpp file?

A1: That is the easiest way to arrange it, yes


Q: is there a reason char is single quotes?

A1: That is the C++ convention to define a char instead of string


Q: can you set a char variable to more than 1 letter or would you need to use a string type?

A1: A char type variable can only hold a single character. Storing multiple characters requires a string


Q: does main have to be int?

A1: Yes, that is convention/required


Q: what is float?

A1: a number with a decimal. For the purposes of this class it’s the same as a double


Q: Im getting an error when I try to include the console.h file: "No such file or directory" what exactly could be going on?

A1: This sounds like you did not install the CS106 speciic components during the install. Can you go back to the Qt install instructions and redo that step (download CS106.zip, build, run)


Q: What happens if you try to set the value of a char equal to a number or a string?

A1: You will get an error if you try to set it to a string. A number might work based on ASCII code


Q: Why is string a different color

A1: That’s just syntax highlighting provided by Qt Creator to help string literals standout from other things


Q: what happens if we do a=a*1.0. error?

A1: live answered


Q: can you use a method to change variable types like in java?

A1: live answered


Q: If you say a = 1.5, will it still run and coerce 1.5 into 1?

A1: live answered


Q: Is string a reference type in cpp like it is in Java or is it more complex than that? I noticed string isn't capitalized like a reference type

A1: There are reference types in C++ but they’re designated differently than in Java. We’ll cover references at some point later this week or early next week.


Q: Is the Stanford library that we are using restrictive since it is not used in industry?

A1: The Stanford library is exclusively used for educational pruposes, yes.


Q: so would the .h file be be under “Sources” in this example?

A1: The .h files are listed under Headers


Q: whats the difference between a float and a double?

A1: They differ in how much decimal precision they can represent (double is twice as precise as float)


Q: why is there a ; after every variable creation?

A1: There is a semicolon to terminate every single line of code in C++.


Q: can you say: int a = 5; double a = 5;? or will that also give a redefinition error

A1: Yes, there can only be one variable with a given name


Q: how is main an integer ?

A1: Main isn’t an int, it returns an int. Every function in C++ is either void or returns a given type


Q: If we have functions, do we always need a .h file to declare them?

A1: You will need a .h to share those functions outside of hte file they were defined in, but if the functions are only used within the one file, you won’t need a separate header for them


Q: Could we do something like float a = 5 on line 10 and C++ would convert 5 to 5.0 under the hood?

A1: Correct!


Q: why might one use a float instead of a double?

A1: Best practice is to just use double by default. You would only bother with float if you were severely space-constrainted and could tolerate lower precision.


Q: Libraries in angled brackets (<>) must be pre-defined by the C++ library right?

A1: Yes


Q: Do you have to initialize all values in the main function?

A1: No, values can be defined in any function as long as they remain in scope


Q: I have moved the file ‘CS106.pro’ to a folder I created called examples, which is the same folder my file is in. Why am I getting an error for #include console.h?

A1: Your projects use the .pro you’ll find in the projets for Welcome, Assign0, etc. (the CS106.pro is for the libraries themselves)


Q: when I type #include, it said error: 'iostream' file not found</i>

A1: This sounds like possibly install issue?


Q: So won’t I be able to do the same stuff that I am learning here, outside the class?

A1: You will, most of this stuff in this class translates to real life. You may see some syntactical changes when not using the Stanford library however.


Q: Do we use single quotes or double quotes for characters?

A1: chars use single quotes


Q: how similar is c++ to java?

A1: They share a fair number of syntactical similarities, though there are certainly important underlying differences that we’ll cover throughout the quarter.

A2: Quite similar in syntax, but rather different under the hood


Q: Should we create a new project for each class/lecture? Or should we try to keep all our files in one project

A1: Separate projects is probably simpler to manage


Q: Why/when should we put a semicolon at the end of a line?

A1: You must put a semicolon at the end of every single line of code. There are additional places where we use semicolons as delimiters (like in for loops) which we will discuss later today/on Friday.

A2: Put a semicolon at the end of every line that is in a function and that doesn’t have a curly brace on it. It tells the computer that the current line is over


Q: If doubles are more accurate than floats, what is the advantage to using floats over doubles? I read that floats hold less memory, but does that stand true if the float value is equal to the double value? (e.g. float 3.0 vs double 3.0)

A1: live answered


Q: Should we make all new projects/files in the same folder as CS106?

A1: Most files for this class will be provided to you!


Q: Will assignments be available ahead of time or is there a specific date each week they will be released?

A1: We release next assignment on due date of previous


Q: do you have to put endl? what would happen if you don’t?

A1: You don’t have to. It just appends a new line character to the end


Q: Can our variable names include underscores i.e. "The_Answer" or does it have to be one word?

A1: We usually avoid use of underscores of variable names in this class. Our standard convention is to use camelCase to name variables with multiple words


Q: can we use C-style print settings (e.g., “%0.5f”) with cout?

A1: I don’t think so. But you can use printf in C++

A2: No, you cannot combine the two, but you cna use printf directly


Q: Where else is the « and » operator used? Does it just pass an argument into a function or is it doing something else?

A1: It is also used in something called overloading, which you’ll learn about later


Q: no need for a + in between the things we are printing?

A1: Not if you use «


Q: So concatenation happens by just using «?

A1: Sort of, « is the operator that “inserts” a value into the output stream


Q: Is "«" and "»" only used in for io? or will we see those elsewhere?

A1: Those two operators are exclusively used for io in the context of this class (they are generally used to process streams, but we won’t really see streams outside of cout in this class)


Q: can we also concatanate strings using +?

A1: Yes.


Q: « are also used in bitwise operations

A1: yes


Q: Is endl equivalent to “\n”

A1: yup!


Q: How did Chris run the code, he did not press the button

A1: Hot key, command-r

A2: He may have a keyboard shortcut confugured to do build + run. I think command-r does this on mac


Q: Can you print integers directly, such as count « 42 « endl;
?

A1: Yes


Q: what are the advantages of using endl instead of "\n"?

A1: More portable, surprisingly the end of line character is not standardized …


Q: '@Paris QtCreator (like other IDE's) have keyboard shortcuts that you can assign at your convenience :)


Q: I run the zip in web and it works, what should I do now?

A1: I’m sorry, but I don’t have the context for this. Can you clarify your question?

A2: Is this for downloading the CS106 library?

A3: I assume this means you were able to complete A0 properly? If so, try downloading this project and writing your code form lecture there: http://web.stanford.edu/class/cs106b/qt/SampleProject.zip


Q: If there is no main() function, the program won’t run?

A1: It won’t build, no.


Q: What would be the main reason to prefer a “do-while” loop instead of a simple while loop?

A1: live answered


Q: do less than or equal to signs exist in C++?

A1: yes! <=


Q: Could we put the entire while loop on one line—curly brackets and all?

A1: yes

A2: Yes, but this would be very bad style!


Q: does c++ use camel for variable names

A1: We do in this class! it’s a style choice

A2: Yes, in this class, we will use camelCase for variable naming.


Q: If i was let’s say equal to double i=4.6354 would main be double main()?

A1: by C++ rules, the main has to return int type

A2: no, you can have variables of different types in one function. int main indicates return type


Q: why is #include “console.h” legal here when console.h is not in the Headers folder?

A1: This is one of the library files that got installed when you installed the Stanford libraries! It’s on your computer, but just hidden from immediate view


Q: where do we need to put our projects if we want them to be able to use the Stanford library? I ran the CS106 project but console.h is still giving a “file not found” error.

A1: Grab blank sample project on web at cs106b.stanford.edu/qt/SampleProject.zip, use this one as template

A2: There’s no specific place you need to put projects. Were you able to successfully complete A0? If so, try using this blank project for writing sample code: http://web.stanford.edu/class/cs106b/qt/SampleProject.zip


Q: could you declare the variable outside the for loop and then just leave it blank before the first semicolon?

A1: yes that is possible


Q: can you put a semicolon after i++/ the update statement?

A1: I don’t think this would compile


Q: are the variables declared inside the initialization statement accessible inside the loop? outside the loop?

A1: Accessible inside the loop, but not outside the loop


Q: Is it possible to elaborate on Do in while loops? Chris mentioned smth like use Do if you want to run at least one… Thank you!

A1: The only difference betwen while and do-whilte is whether the test for continuing to loop is tested at the “bottom” of the loop or the “top”. By far, most loops will be for or while, do-while is rare


Q: if i=0, isn’t it always less than 3? and would the loop go through if int i=1?

A1: Note the i++ in increment step — i goes up by one each loop iteration


Q: In what order does std::cout evaluate its arguments?

A1: Things will be printed from left to right


Q: When we create a new project, how do we make sure that we include the stanford libraries?

A1: you #include the relevant files


Q: Question - does c++ change the value of i depending on what happens in the function, or will it definitely run this 3 times. For example, if within the for loop I wrote i=i+1, would this run 3 times or only 2?


Q: what does i++ mean?

A1: live answered


Q: Does it check the condition before the first execution?

A1: yes

A2: Yes, so it is possible for the for loop to never run if the condition evaluates to false right after the initialization statement.


Q: Is console.h some global library then? accessible by all projects made on QT-creator?

A1: It is part of our Stanford-specific libraries


Q: why didn’t #include “all-examples.h” at the beginning?

A1: We haven’t declared any funciton prototypes yet, so there’s no need for a custom header file yet

A2: I think Chris was just using that header file to demosntrate how to use #include


Q: does the for loop have to use a new var in the init statement? can you use a var that you used/declared in a previous part of the program?

A1: live answered


Q: why the left } always on a new line

A1: Stylistica convention that makes the code better organized and easier to read

A2: it’s stylistic. It let’s you know where the proper indentation should be


Q: If you wanted to increment i by two instead, how would that look?

A1: i+=2


Q: sorry right }


Q: can do you i < = 3 with the same syntax as Java?

A1: yes


Q: Oh okay! I remember following the instructions step by step but i think i may have missed something! thank you


Q: '@paris Li —> its a style choice, It could be on the same line


Q: does c++ change the value of i depending on what happens in the function, or will it definitely run this 3 times. For example, if within the for loop I wrote i=i+1, would this run 3 times or only 2? and the program would then print only 0 and 2?

A1: it would only run 2 times!


Q: '@Chase do we create a new project within the CS106 folder that we downloaded and then unzip instead of creating a project outside that folder?

A1: If you want to create new projects, use this as a template: http://web.stanford.edu/class/cs106b/qt/SampleProject.zip

No need to do anything with CS106.zip after initial library installation

A2: ^^ also for most projects in the class we will give you starter code to download


Q: How does the compiler know where the Stanford console.h file is?

A1: Specified in the .pro file which is bundled as part of the project


Q: Do we must write our code under the same file contain library file?

A1: I don’t quite understand your question, can you clarify?


Q: can we change loopVar within the loop?

A1: yes, but it makes things confusing so be careful with this


Q: I see Chris is still indenting even though the indentations aren't functionally important. Is it stylistically better that we still indent our functions?

A1: Yes!! Thank you for asking!

A2: Yes it is stylistically better and makes code easier to read.

A3: Yes, indentation is very, very important when it comes to style and readability fo your code. This is one of the components your assignments will be graded on this quarter


Q: Do you have style preferences for use of curly brackets in the case that a control flow statement’s content is a singular line?

For example, I had a prof in a previous C++ based class who preferred we used curly brackets only if the content of the decision-making statement required more than 1 step (spans more than 1 line) and otherwise, indent and include the procedure of the loop in the line below without brackets just end the single line with the semicolon like:

if (i < 5) cout « “i is less than 5” « endl;

instead of

if (i < 5) { cout « “i is less than 5” « endl; }</i>

A1: We prefer that you use braces aways — less error-prone. See https://web.stanford.edu/class/cs106b/resources/style_guide.html for more tips


Q: By declaring a variable inside of a loop, does that not try to redeclare every iteration? (ie. “int insideVar = ” as opposed to declaring outside of the loop and just saying “insideVar =“

A1: it does redeclare in every iteration


Q: What is “using namespace std”?

A1: if you don’t include it you have to type std in a lot of places. for example you would type std::cout instead of just cout. including this gets rid of the need to type std::


Q: Does the for loop increment happen at start or end of the loop?

A1: At the end of the loop (first increment won’t happen until body of loop has happened once)


Q: so earlier we could only initialize a variable once. However is it possible if you use a loop like in this example?

A1: The initialization step of the loop still only happens one time


Q: Since variables belong to their block could you call insideVar from inside forloop

A1: yes


Q: Do names always have to be in camelcase?

A1: live answered

A2: It’s a stylistic choice. For this class this is the style we will use


Q: Is it acceptable to use first_last format for naming variables and functions?

A1: live answered


Q: is it possible to get the variable from within a loop?

A1: A varibale declared in a loop will still persist after the loop, but you need to be sure that the loop ran. This is not the same for if statements however


Q: Without using namespace std, would we have to type std:: only in front of the functions in the standard library (not in front of functions in io or string or console.h)?

A1: yes, that is correct. you have to say std::string instead of string, which gets annoying quick


Q: Does scoping result from creating the stacks? So like the for loop's variables are on a different stack call?

A1: There is a separate stack frame associated with each function call, but there is also a division of those variables into scopes (visibility) within the function too


Q: including blank header files should still be legal right? Since we are just pasting nothing into the file. So why didn’t “all-examples.h” give an error?


Q: why does scoping occur?

A1: live answered


Q: ^^ Than main's stack call. Hence main doesn't have access to the loop's variables?


Q: Correction: including blank header files should still be legal right? Since we are just pasting nothing into the file. So why did including “all-examples.h” give an error?

A1: I’m not sure, hard to tell what was happening there. Generally including a blank header file would be legal (but useless)


Q: are there situations where changing a variable inside the for loop will only change the variable in the inside scope, but not the outside scope?

A1: live answered


Q: Can you reinitialise a variable outside a scope?

e.g. for (….){ int a =5 }</i>

A1: yes!


Q: char a=a


Q: Can we always define varibles outside, and assign values inside the loop?

A1: yes


Q: Can a variable with a smaller scope hide a var with the same name?

A1: live answered


Q: So if the variable is declared outside of the loop and then manipulated inside a loop, the changes will remain when you leave that loop? Like that variable won’t disappear?

A1: Yes


Q: Sorry my english is bad, is there a help section after class?

A1: Yes, Chris is having office hours from 11:30-1:30 if you’re still running into Qt issues

A2: Yes, please come!


Q: what’s camel case? C++’s version of snake case?

A1: Yes

A2: Camel case is a variable naming strategy where the first word alwats starts witha lower case letter and all remaining words start with upper case letters like oneTwoThree instead of one_two_three


Q: So in that example if we printed insideVar outside the loop it would be 7?

A1: I’m not sure exactly which example is being reference, but you would not have access to insideVar outside the loop because its scope is only inside the loop


Q: '@Kheli camel case is where you type two words like this —> twoWords


Q: Would declaring insideVar within the for loop save memory/improve run times? What’s the reason for scoping it/its advantages?

A1: Any runtime changes would be negligible. However, this could change functionality so please watch out for this

A2: No change in memory, but it is good practice to limit the visibliity to what is needed and no larger to avoid errors


Q: Inside the scope in this case is also inside the for-loop curly brackets? So we won’t be able to use “insideVar” ourside of for-loop curly brackets, is it correct?

A1: Correct


Q: a variable with a global scope can be temporarly changed in a function, right? isn't it changed by something called passed by value? can you verify that?

A1: Global variables are generally considered to be very bad style, so we won’t be working with them this quarter. We’ll talk about functions and pass-by-value on Friday I believe


Q: Thank you, will do.


Q: will we talk about when we should/shouldn’t define our variables globally

A1: Most times you will want to avoid global variables in this class as it is considered bad style generally

A2: No global variables, please! See https://web.stanford.edu/class/cs106b/resources/style_guide.html for more style tips

A3: We will never use global variables in this course – it is generally considered to be bad style, at least for the applicartions we have in this class


Q: can you clarify a=b vs a==b?

A1: live answered


Q: would ?: be considered a boolean operator? expression?

A1: Sometimes called the “ternary expression”


Q: do you need the endl if you are only printing one line of code?

A1: No


Q: why does the main function need to return 0?

A1: C++ rules require that main return an int, used as a “status code”

A2: Established C++ convention carried over from C


Q: are the curly braces needed if there is only one line after the if(a==b)?

A1: No


Q: Does it matter if we write variables like firstVariable or first_variable? Does this class have a preference?

A1: Yes, we are camelCase. See https://web.stanford.edu/class/cs106b/resources/style_guide.html for more style tips


Q: '@Ryan, thank you!


Q: Are there triple === in C++?

A1: No

A2: No


Q: If I'm not wrong, isn't there something like a === b as well?

A1: No, not in C++


Q: '@Kheli you’re welcome!


Q: is 0==“0” true?

A1: No


Q: This is going back in the lecture a bit, but if I initialized a with "int a = 5;", but later in the program, I want to use "a" as a double, how do I "delete" the previous initialization?

A1: live answered


Q: is 1==true true?

A1: live answered


Q: when comparing strings do we use something similar to .equal()

A1: No you can use == to compare strings in C++


Q: difference between else if and elif, syntax wise?

A1: elif doesn’t exist in C++, you must use else if


Q: when you are returning 0 at the end of the main function, what is that 0 being returned to?

A1: To the operating system. A return of 0 says “program executed fine and exited normally”


Q: In C++ can you not use squiggly brackets if it is only one line of code like in Java?

A1: yes


Q: 679928


Q: what does the .pro file do in QT?

A1: it contains all of the information needed for a project

A2: It configures the build settings


Q: Is it bad practice to do the last statement in an if/elseif/else set as an elseif a>b just for ease of understanding purposes?

A1: no, that’s fine


Q: can we chain equalities like a == b == c?

A1: no, you’d do a== b && b== c

A2: That construct is legal, but doesn’t do what you intend, watch out!


Q: what are the red and green color on the line number

A1: it indicates changed lines


Q: What happens if you just type in a single & ot |?

A1: You should avoid those in this class. They do bitwise operations, which you’ll learn about in CS107

A2: it’s called a bitwise operator. This is 107 content


Q: I can’t see on the style guide a preference or reason to prefer either. If we have a large number of conditions, is there a preference between using switch cases or using if/else if iterations/else control statements?

A1: live answered

A2: switch applies only in the particular case that you have integer value cases, so mostly you’ll use if/else if


Q: So the only reason not to use (and) or (or) is because stylistically this class prefers it? Do we get style marks off for not conforming

A1: You can use either for this class. There are other style rulese we are more prescriptive about, see https://web.stanford.edu/class/cs106b/resources/style_guide.html


Q: Is it a bitwise operator?

A1: yes


Q: what does & mean

A1: this is 107 material

A2: It is a bitwise operator, which you’ll leanr about in CS107. Not necessary for this class.


Q: Do integers in C++ have a true/false value?

A1: We use bool type for true/false (but yes non-zero ints are treated as true, and 0 equates to false)


Q: When I do “else (a == b && b == c){}” it says expected ; after expression — where would the semicolon go?

A1: you would use else if () {} and the semicolon goes on any line inside of the curly braces


Q: where do we find the link to office hours for CS106B?

A1: https://web.stanford.edu/class/cs106b/restricted/zoom_info

A2: Quick link on right side of course home page


Q: can you do if(… && …. &&)

A1: Yes


Q: Can you run through the process of creating a new project? Should we copy and paste the sample project, or should we go File > New File/Project? If so then which settings should we pick to set it up to work with the CS106 library. Thanks!

A1: Copy this folder, and open the .pro file. That should be all you need to do. http://web.stanford.edu/class/cs106b/qt/SampleProject.zip


Q: Julie, what’s the best way I can reach you if I want to discuss non-CS106B related topics?

A1: live answered


Q: '@Julie, thank you! Will use camelCase. Is C++ technically capable of using snake_case?

A1: Yes, C++ itself doesn’t really care

A2: Yes, C++ itself agnostic, our class has its own preferences


Q: When I tried to open Assignment 0 in Qt, it said I could not open it because the file path contained an invalid characer, which was ~. However, the ~ was part of the file path produced by iCloud Drive, which is where I store my assignments. Is it possible to work around this or will I have to always store my assignments locally?

A1: live answered


Q: General question, how big is the class?

A1: live answered


Q: Awesome, thanks!


Q: Is there a way I can confirm my Assignment 0 google form response was received?

A1: live answered

A2: email chase and nick


Q: Will Friday's lecture start with a new slide deck? Or will we start Friday's lecture by finishing up this slide deck?

A1: live answered


Q: '@nick so i just copy it for all my projects?

A1: Yes

A2: For any personal projects you want to use. For section/assignments we will provide specific starter code.


Q: Is there an easy way to extract the makefile from the .pro file? I REALLY dislike IDEs and would greatly prefer Vim + make + gcc + gdb on the command line

A1: live answered


Q: Would it likewise cause errors to sinc program files with google drive?

A1: Most likely yes. I’d reccommend dowloading locally


Q: can you use “return” in different ways? can you return a string or integer?

A1: yes!


Q: Is the code that was written in the lecture going to be posted on the website?

A1: Yes, Chris usually posts the lecture code on the lecture pages.


Q: After this class, should I take CS 107 or CS 103?

A1: up to you! 107 is more code and 103 is more theory

A2: We’ll talk about this at the end of the quarter, but you can go to either. It depends on what your goal are, but the most common path is to 107.


Q: Can someone like new who is very good(learned composition and arrays) in Java do well in CS106B?

A1: live answered


Q: if you define a variable in main and then call a function from main, will that variable be visible in the function or do you have to use parameters/arguments

A1: you have to pass the variable as a parameter


Q: Could you explain how to use the ReferenceExamples file to code our own projects?

A1: live answered


Q: Going back to when we were talking about typed variables - do we get an error when re-typing the same variable (trying int a = 5 and then int a = 12) because it tries to create a new int object variable/what’s the reason for the error?

A1: It’s an error because you cannot decalre a variable with the same name twice int he same scope


Q: I’m confused on what the “ #include “ functions as. I know you mentioned libraries but I am confused to what that means.

A1: live answered


Q: Does this cause confusion when I take Java and C++ at the same time, since I just learned Python before?

A1: I don’t think this would cause confusion as long as you have an appropriate background for this class


Q: How do u open a blank doc in qt creator in order to test different things?

A1: live answered


Q: Could someone further explain the whole std and namespace thing?

A1: live answered


Q: if you declare int i = 0 outside the for loop, does your for loop say for( i < 10; i++){//code} or for(i = 0; i < 10; i++){//code}

A1: live answered


Q: is there a lot of content in the textbook readings that are not covered in lecture (that we are responsible for)?

A1: Everything that you need to know will be discussed in lecture

A2: No, the textbook readings are supplementary


Q: How long should Assignment zero typically take? I just signed up today

A1: 30 mins or so, its quick


Q: Which is the #include statement to import the Stanford library?

A1: #include “console.h” is referencing a specific part of the Stanford library

A2: There is no #include to include the entire library


Q: why was QT creator chosen?

A1: Cross-platform compatiblity


Q: Why don't we need semicolons for the #include statements?

A1: That’s just part of the syntax – lines of code starting with # do not end with a semicolon


Q: where do you fine the sample project template?

A1: http://web.stanford.edu/class/cs106b/qt/SampleProject.zip


Q: how does the compiler find the cs106b library?

A1: Configured by the .pro file


Q: Is the « operator specific syntax for printing, or does it have a more general meaning?

A1: It has other meanings but we won’t cover those in this class (it is used as a general stream operator)


Q: Do you use access modifiers on C++ functions like you would on Java methods

A1: Only on member functions within a class, not on global functions


Q: Is assignment 0 the only required assignment for this week?

A1: yes

A2: yes


Q: Thanks!


Q: Why is a debug folder created when debugging? Can we delete these?

A1: live answered