Question

C++,please help. I have no idea how to do that begining with zero parameter constructor. and help me to test the method,

Write a class template Square Matrix that implements a square matrix of elements of a specified type. The class template shou

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Zero parameter constructor is the constructor which will not accept the arguments/Parameters.

Eg :

#include <iostream>

using namespace std;

class Demo

{

private:

int A;

int B;

int C;

public:

Demo();

void set(int A, int B, int C);

void print();

};

Demo::Demo()

{

A=1;

B=1;

C=1;

}

void Demo::set(int A, int B, int C)

{

this->A = A;

this->B = B;

this->C = C;

}

void Demo::print()

{

cout<<"Value of A : "<<A<<endl;

cout<<"Value of B : "<<B<<endl;

cout<<"Value of C : "<<C<<endl;

}

int main()

{

Demo obj = Demo(); //Constructor called when object created

obj.print();

obj.set(10,20,30);

obj.print();

return 0;

}

Here, demo is the default / Zero parameter constructor.

Add a comment
Know the answer?
Add Answer to:
C++,please help. I have no idea how to do that begining with zero parameter constructor. and...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • C++ CODE: The matrix class consists of two files: matrix.h and matrix.cpp. The class has the...

    C++ CODE: The matrix class consists of two files: matrix.h and matrix.cpp. The class has the following definition: matrix -size:int -mat:int** ---------------- +matrix(file:string) +~matrix() +operator +(add:matrix*):matrix & +operator-(sub:matrix*):matrix & +friend operator<<(out:ostream &, t:const matrix&):ostream & +displayRow(r:int):void The class variables are as follows: • size: the number of rows and columns in a square matrix • mat: the integer matrix that contains the numeric matrix itself. The methods have the following behaviour: 2 • matrix(file:string): The default constructor. It receives the...

  • Language is C++ Basic principles and theory of structured programming in C++ by implementing the class:...

    Language is C++ Basic principles and theory of structured programming in C++ by implementing the class: Matrix Use these principles and theory to help build and manipulate instances of the class (objects), call member functions Matrix class implementation from the main function file and, in addition, the Matrix class must have its interface(Matrix.h) in a separate file from its implementation (Matrix.cpp). The code in the following files: matrix.h matrix.cpp matrixDriver.h Please use these file names exactly. Summary Create three files...

  • Hi all, I need help to do a project based on C++ smart pointers. I have...

    Hi all, I need help to do a project based on C++ smart pointers. I have to implement the class template my_unique_ptr which is a pointer management class template. Also, it's required to implement the following public methods: a. Default constructor that initializes the object to point to nullptr. b. Constructor that takes a pointer Type * as a parameter and sets the object to point there. We say that the newly created object takes ownership of the pointed memory....

  • I only need the "functions" NOT the header file nor the main implementation file JUST the impleme...

    I only need the "functions" NOT the header file nor the main implementation file JUST the implementations for the functions Please help, if its difficult to do the complete program I would appreciate if you could do as much functions as you can especially for the derived class. I am a beginer so I am only using classes and pointers while implementing everything using simple c++ commands thank you in advanced Design and implement two C++ classes to provide matrix...

  • (C++) Two stacks of the same type are the same if they have the same number...

    (C++) Two stacks of the same type are the same if they have the same number of elements and their elements at the corresponding positions are the same. Overload the relational operator == for the class stackType that returns true if two stacks of the same type are the same; it returns false otherwise. Also, write the definition of the function template to overload this operator. Write a program to test the various overloaded operators and functions of classstackType. **Please...

  • Implement the following in c++ (use "iostream" and "nsmespace std" please.)

    Implement the following: a. A template class named MyArray. 1) MyArray is a dynamic partially filled array for primitive types. 2) data members: - a pointer for the array - any associated variables needed to manage the array. 3) Constructor must insure that specified capacity is possible. Exit the program if an illegal value is specified. 4) “The Big Three” are required to insure deep copy. 5) Private grow function is used to automatically increase the size of the array...

  • Please help me out with this assignment. Please read the requirements carefully. And in the main...

    Please help me out with this assignment. Please read the requirements carefully. And in the main function please cout the matrix done by different operations! Thanks a lot! For this homework exercise you will be exploring the implementation of matrix multiplication using C++ There are third party libraries that provide matrix multiplication, but for this homework you will be implementing your own class object and overloading some C+ operators to achieve matrix multiplication. 1. 10pts] Create a custom class called...

  • In C++ and comment so I UNDERSTAND Implement a class named DynamicArray that has the following...

    In C++ and comment so I UNDERSTAND Implement a class named DynamicArray that has the following members: A pointer to hold a dynamically allocated array, of type int. A member variable to hold the size of the array. A default constructor, which will allocate an array of size 10 A parameterized constructor, which takes a size and use the size to allocate array. A copy constructor, which performs deep copy. A copy assignment operator, which performs deep copy and supports...

  • NO VECTORS PLEASE Start a simple Matrix template class In this lab, you’ll be writing a...

    NO VECTORS PLEASE Start a simple Matrix template class In this lab, you’ll be writing a template class to represent a matrix. Because it’s a template, your matrix class will be able to work with different types of underlying data. Start by creating a new file matrix.hpp. Inside this file, start to write your matrix template class. Here’s a start for the class definition: template <class T> class Matrix { private: int _rows; int _cols; T** data; public: Matrix(int rows,...

  • C++ Assignment - Only Implementation file( VectorDouble.cpp file) required. The header file is already given. Please help, thumbs up guaranteed. Chapter 8 discussed vectors, which are like arrays that...

    C++ Assignment - Only Implementation file( VectorDouble.cpp file) required. The header file is already given. Please help, thumbs up guaranteed. Chapter 8 discussed vectors, which are like arrays that can grow in size. Suppose that vectors were not defined in C++. Define a class called VectorDoublethat is like a class for a vector with base type double. Your class VectorDoublewill have a private member variable for a dynamic array of doubles. It will also have two member variables of type...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT