OOP344 Lecture 4 – Week 3 // MACROS & PreProcessing

So in today’s OOP344 class we discussed Macros and Preprocessors

Named Things include:

– Classes, Functions, Variables, Member Variables, and Namespaces

Preprocessor Directives include:

– #include “path begins in directory local to this filename”

– #ifdef, #ifndef, #endif, #else, #elseif, and some others

So a simple example of macros would be the following image(s)Image:

Macros can be tricky because of parentheses and BEDMAS, but not to worry, with a couple more examples, it will all makes more sense!

The following is a worksheet we received in class to complete in class, which used a bunch of cool macro concepts:

Image

 

Results from the quiz we did 1st class

Consider the following class (you may not change this header):

class Badger {

char* _storage;

public:

Badger();

Badger(const char*);

Badger(const Badger&);

~Badger();

void set(const char*);

void print() const;

int length() const;

};

The Answers are as follows in the image below that I have attached:

OOP344 Quiz Answers

 

In the image above, the code describes use of string library functions, along with copy constructors and deconstructors, as well as non-default constructors (a constructor which accepts a value and sets it at the start of run time) (rather than simply going into the default constructor)

OOP344 – Lecture & Week #2

This week in OOP344 we did:

– Retrieval of Wiki credentials

– GitHub Review & Commands

So the first topics I’m gonna cover in this post are the github commands:

1) git branch: Shows the current branch you are in.

2) git checkout – – <file_name> : Removes changes to a file.

3) git status: Checks for changes in a file or repo.

4) git checkout <branch_name>: Switch to specified branch.

5) git add: Adds files to a branch (current branch).

6) git commit – -help: Online/Offline help pertaining to git commit commands.

7) git config: Used to configure authors and emails pertaining to your account.

8) git branch -d <branch_name>: Deletes the specified branch.

9) git branch -b <branch_name>: Creates and switches to your new branch within 1 command.

10) git commit -m “Message”: To commit and add a message rather than create a file containing the commit message. This method is faster and much easier to use since all the work is done through the command itself.

11) git add -u: To add all modified files rather than typing out their entire name. This method, like the last, is simpler and faster because all the work to be done is being done within the command itself.

Another topic we covered pertaining to git commands include “Adding a new file to a branch”

1st step: git checkout <branch_name> ->switch to your desired branch

2nd step: git add <file_path> -> add the file into the branch repo

3rd step: git commit -m “Message” -> commit the file and include the message pertaining to the changes made to that file

4th step: git status -> this will check the status on all commits made.

So thats pretty much everything we covered in our first official lecture of OOP344.

Feel free to comment any other commands you may know of!!!!!!