Connecting...

This is a quick preview of the lesson. For full access, please Log In or Sign up.
For more information, please see full course syllabus of Intermediate C++
For more information, please see full course syllabus of Intermediate C++
Intermediate C++ Overview of Intermediate C++
Lecture Description
In this lesson, our instructor Alvin Sylvain goes through an introduction on an overview of Intermediate C++. He touches on the topics he'll be discussing in this course: Containers, vector, list, set, map, templates, object oriented programming, operator overloading, exception, exception handling, namespaces, input, output, functions, types, pre-compiler macros, and compiling the code.
Bookmark & Share
Embed
Share this knowledge with your friends!
Copy & Paste this embed code into your website’s HTML
Please ensure that your website editor is in text mode when you paste the code.(In Wordpress, the mode button is on the top right corner.)
×
- - Allow users to view the embedded video in full-size.
Next Lecture
Previous Lecture
1 answer
Mon Nov 4, 2013 7:41 AM
Post by Karen Brown on November 3, 2013
Okay, there is a function called "add" and a class called "option", and we have to pass a constructor into it. It looks like this:
c->add(new option("sure",5));
I am confused on how to write the function "add". I have never had to pass a constructor before. I do not know how to write the parameters or anything.
Thanks!
2 answers
Last reply by: Karen Brown
Sun Nov 3, 2013 6:55 PM
Post by Karen Brown on November 3, 2013
OK...there is this one function that is like a double function, and I keep getting memory leaks
Question?? How do I pass a new choice class constructor that takes 2 arguments to a function?
1 answer
Wed Sep 25, 2013 5:49 AM
Post by Karen Brown on September 24, 2013
Hello Professor Sylvain,
Here is an assignment that I received from my college computer class.
I did not understand any of this, nor did the students that I was collaborating with.
Assignment Description:
You will be creating a class that models the mathematics construct of a Matrix. A Matrix is a 2-dimensional structure, you will model this with 2d dynamic array. Your matrix will be able to add itself to another Matrix object and a couple other operations.
matrix.hpp
class Matrix : public LoggableIfc
{
public:
Matrix(int rows = 0, int cols = 0);
Matrix(const Matrix& m);
~Matrix();
Matrix operator=(Matrix);
int* operator[](int);
//Addition functions
Matrix add(const Matrix &m) const;
Matrix operator+(const Matrix& m) const;
static int getMatrixCount();
private:
int rows;
int cols;
int **data;
static int matrixCount;
};
int Matrix::matrixCount = 0;
Function Description
int* operator[](int n);
Overloaded square brackets '[]' for Matrix class,
returns the nth integer pointer column
Matrix operator+(const Matrix& m) const;
return the sum of two matrices
static int getMatrixCount();
return the value of matrixCount
matrix input file (a, b, c, d)
You will need to read in 4 matrices from a file. You need to check the upload site for the exact names, but generically, they are named as follows:
•matrix.a
•matrix.b
•matrix.c
•matrix.d
Each input file will be of the form....: rows
cols
0,0 0,1 0,2...
1,0 1,1 1,2...
...
Example: 3
4
34 23 23 65
45 234 42 64
324 34 654 21
Driver (Showoff)
This is a mandatory file in which I expect you to show off your new class. You will want to test things like: •A+B
•B+B
•C+D
•A+B+C+D
•A+A+B+B+C+C+D+D
Testing Files
Testing each class you create is mandatory and must have 3 tests for each function in the class. You do not have to test the destructor.
Thanks!