im studying data structuer using c++ in my 1st year
i wrote a c++ programme using class called vector for hangling n-dimrnsional vector..
but i had errors when compiling i don't know why & whats the right solution
It would help if you told us what are these errors of which you speak.
I would like to warn you that you're coming very close to having a naming conflict with the class "vector" in the C++ standard library. The only thing that's stopping you from having it (as far as I can see) is the fact that you didn't #include <vector>. :/
--------------------Configuration: 1 - Win32 Debug--------------------
Compiling...
1.cpp
C:\HW\1.cpp(29) : error C2533: 'vector::vector' : constructors not allowed a return type
C:\HW\1.cpp(64) : error C2264: 'vector::vector' : error in function definition or declaration; function not called
C:\HW\1.cpp(68) : error C2676: binary '[' : 'class vector' does not define this operator or a conversion to a type acceptable to the predefined operator
C:\HW\1.cpp(68) : error C2676: binary '[' : 'class vector' does not define this operator or a conversion to a type acceptable to the predefined operator
C:\HW\1.cpp(78) : error C2264: 'vector::vector' : error in function definition or declaration; function not called
C:\HW\1.cpp(82) : error C2676: binary '[' : 'class vector' does not define this operator or a conversion to a type acceptable to the predefined operator
C:\HW\1.cpp(82) : error C2676: binary '[' : 'class vector' does not define this operator or a conversion to a type acceptable to the predefined operator
C:\HW\1.cpp(91) : error C2556: 'double __thiscall vector::operator +(class vector)' : overloaded function differs only by return type from 'class vector __thiscall vector::operator +(class vector)'
C:\HW\1.cpp(22) : see declaration of '+'
C:\HW\1.cpp(91) : error C2371: '+' : redefinition; different basic types
C:\HW\1.cpp(22) : see declaration of '+'
C:\HW\1.cpp(91) : error C2084: function 'class vector __thiscall vector::operator +(class vector)' already has a body
C:\HW\1.cpp(96) : error C2676: binary '[' : 'class vector' does not define this operator or a conversion to a type acceptable to the predefined operator
C:\HW\1.cpp(118) : error C2264: '+' : error in function definition
or declaration; function not called
C:\HW\1.cpp(118) : error C2088: '+' : illegal for class
Hmm. cl.exe has a funny way of saying "missing a semicolon after the class declaration".
That aside, you forgot to define a few operators. You forgot to define operator[] for use in your operator definitions. Also, do you have a typo on line 90? It looks as though you have one character that's not quite what it's supposed to be. :)
i carried out what u noticed me ..but i still have this strange error i don't know wts wrong now
& wt u said about "define operator[] for use in your operator " i did'nt take any thing about that in university ..so i didn't know wt u meant ..
here's the error's i had - !!!!!
--------------------Configuration: 1 - Win32 Debug--------------------
Compiling...
1.cpp
C:\HW\1.cpp(72) : error C2676: binary '[' : 'class vector' does not define this operator or a conversion to a type acceptable to the predefined operator
C:\HW\1.cpp(72) : error C2676: binary '[' : 'class vector' does not define this operator or a conversion to a type acceptable to the predefined operator
C:\HW\1.cpp(86) : error C2676: binary '[' : 'class vector' does not define this operator or a conversion to a type acceptable to the predefined operator
C:\HW\1.cpp(86) : error C2676: binary '[' : 'class vector' does not define this operator or a conversion to a type acceptable to the predefined operator
C:\HW\1.cpp(101) : error C2676: binary '[' : 'class vector' does not define this operator or a conversion to a type acceptable to the predefined operator
Error executing cl.exe.
The above errors mean that you wrote codes to call function of vector::operator[](), but you don't define it yet. For example in line 72, you wrote "tmp[ir]= array[ir]+m[ir]", both tmp and m are vector type, but vector doesn't have operator[] defined. To define it, just like to define other operators such as operator+, operator- etc.