Hi guys,
well i am learning c++ on my own..
i am studying it by refering to the book and doin its exercises.
well i need help sorting out the errors.. and i am not sure wat destructors and constructors are.. plus i am coding using Visual C++ 2008 express edition..
this program needs me to input a matrix from a file..
the file called matrix1.txt is as follows:
<matrix>
rows = 2
cols = 2
1 2
2 4
</matrix>
so we are meant to input the data from the file into the matrix and carry out the operations..
the code is as follows for Matrix.h
8 1970
Why do you ask? What happened when you tried to compile and run your code?
Please enclose your code in [i][code=cpp[/i]] ... [/code] tags.
hi i got lots of errors.
i tried for a few hours to reduce them..
i managed to bring it down from abt 120 errors to 43 errors..
and i tried my best to correct each error..
but looks like i need more experience or help before i can fix them
could u please help me spot the errors?
and teach me how to use the destructos and constructors?
thanks
hi i got lots of errors.
i tried for a few hours to reduce them..
i managed to bring it down from abt 120 errors to 43 errors..
and i tried my best to correct each error..
but looks like i need more experience or help before i can fix them
Is there anything more difficult than missed declaration?
just a few
1) Ewe never allocate memory for m[][], it will crash on first run.
2) in multiplymatrix there is no m1 variable in scope, and m3 elements are left unitialized before ewe add values to them.
eta-47: error: ISO C++ forbids declaration of `readMatrixFile ' with no
type
- so what? add void in front of as in class declaration
::transposeMatr ix()
int save[2][2];
totaly wrong - use double as temp and I eve don't understand how is it supposed to work
m3 is not defined as well
error: no match for 'operator[]' in 'm3[a]'
Yes. Use m3.m[a] instead - from class methods ewe can access private members of classes of your type.
[quote=newb16][quote=slizorn]hi i got lots of errors.
i tried for a few hours to reduce them..
i managed to bring it down from abt 120 errors to 43 errors..
and i tried my best to correct each error..
but looks like i need more experience or help before i can fix them
Is there anything more difficult than missed declaration?
just a few
1) Ewe never allocate memory for m[][], it will crash on first run.
2) in multiplymatrix there is no m1 variable in scope, and m3 elements are left unitialized before ewe add values to them.
yea about the allocating memory for the m[][]... how do i do it?
i have a rough idea that i got to use new and delete or somethin like that..
but not sure how...
could ya gimme an example for the case where the max size of the matrix is say 10 by 10?
and the thing with (2).. i want to be able to do m1.multiplyMatr ix(m2, m3);
but i get wat u mean but how am i to do it by initialize the m3 elements?
thanks
yea about the allocating memory for the m[][]... how do i do it?
like m=new (double*)[10]; for(i...) m[i]=new double[10];
and... for(i...) delete[] m[i]; delete[] m;
and the thing with (2).. i want to be able to do m1.multiplyMatr ix(m2, m3);
but i get wat u mean but how am i to do it by initialize the m3 elements?
thanks
You need to set each element of m3 to 0 before addition - i.e. before the innermost loop.
like m=new (double*)[10]; for(i...) m[i]=new double[10];
and... for(i...) delete[] m[i]; delete[] m;
You need to set each element of m3 to 0 before addition - i.e. before the innermost loop.
errm when i did wat u said for the 1st thing.. i jusut get abt 60 more errors... i dun think that is solving the problem.. if u want i can send u the files.. i cant attach it to this forum for some reason..
thanks
I do not sly neponyal nothing. gugltransleyt some hnyu extradite apologize. Send-a ... in profile button pm - sends nivapros.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: murali |
last post by:
Hi,
I get tollowing linking errors
Main.cpp:30 undefined reference to
Matrix<int>::Matrix(int,int)
whats that '' and what might be the problem ??
line 30 of main: Matrix<int>::Matrix(array,int rows,int cols)
|
by: Jason |
last post by:
Hello. I am trying to learn how operator overloading works so I wrote
a simple class to help me practice. I understand the basic opertoar
overload like + - / *, but when I try to overload more complex
operator, I get stuck.
Here's a brief description what I want to do. I want to simulate a
matrix (2D array) from a 1D array. so what I have so far is something
like this:
class Matrix
|
by: Charulatha Kalluri |
last post by:
Hi,
I'm implementing a Matrix class, as part of a project. This is the interface
I've designed:
class Matrix( )
|
by: H. S. |
last post by:
Hi,
I am trying to compile these set of C++ files and trying out class
inheritence and function pointers. Can anybody shed some light why my
compiler is not compiling them and where I am going wrong?
I am using g++ (GCC) 3.3.5 on a Debian Sarge system. The compiler complains:
//****************************
//**************************** Compiler output starts ***********
cd /home/red/tmp/testprogs/
|
by: christopher diggins |
last post by:
Here is some code I wrote for Matrix multiplication for arbitrary
dimensionality known at compile-time. I am curious how practical it is. For
instance, is it common to know the dimensionality of matricies at
compile-time? Any help would be appreciated. Hopefully this code comes in
useful for someone, let me know if you find it useful, or if you have
suggestions on how to improve it.
// Public Domain by Christopher Diggins, 2005
...
| |
by: pmatos |
last post by:
Hi all,
I have implemented a matrix template to suit my needs and now I've
implemented some methods for computing SVD decomposition of
Matrix<double>.
I have:
template <class T>
class Matrix {
public:
....
|
by: andrea |
last post by:
I'm studying some graphs algorithm (minumum spanning tree, breath
search first topological sort etc etc...) and to understand better the
theory I'm implementing them with python...
I made my own graph class, the constructor is simply this:
class graph:
"in forma di matrice e' una matrice normale, in forma di lista uso un
dizionario"
def __init__(self,nodes,edges,dir=False,weight=): # inizializzatore
dell'oggetto, di default in forma di...
|
by: DarrenWeber |
last post by:
Below is a module (matrix.py) with a class to implement some basic
matrix operations on a 2D list. Some things puzzle me about the best
way to do this (please don't refer to scipy, numpy and numeric because
this is a personal programming exercise for me in creating an
operational class in pure python for some *basic* matrix operations).
1. Please take a look at the __init__ function and comment on the
initialization of the list data...
|
by: mohammaditraders |
last post by:
Write a program which overloads a binary Minus (+) operator,
The program will contain a class Matrix, This class will contain a
private data member Array which store int values. The class will
further contain a Default constructor, get() function which takes
values for array from the user and also contain a Display function
witch display the array on the screen,
In main function create three objects Mat1, Mat2, Mat3 of this class,
first...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |