|
|
|
|
|
|
|
|
I want this to work out: c[i] = a[i] + b[i] for all the values i |
int size() const { return m_dim; } //returns size of vector
etc.
|
|
|
|
// note: move construtor amd move assignment are implicitly deleted
// note: move construtor amd move assignment are implicitly deleted
// note: move construtor amd move assignment are not implicitly declared
at()
that provided checked access (a la vector).for( int i = 0 ; i < seq.size() ; ++i ) seq[i] = 8 ;
m_p( new float[n]{} )
; everything else is C++98 compatible. EDIT: And the noexcept
for the destructor.VectorFloat& VectorFloat::operator += ( float f ) ;
.a = a + 3 ;
overload VectorFloat operator + ( VectorFloat vec, float f) ;
|
|
|
|
|
|
1> main.cpp 1>c:\users\cullan\documents\visual studio 2012\projects\assignment 1\assignment 1\vectorfloat.h(3): error C2011: 'VectorFloat' : 'class' type redefinition 1> c:\users\cullan\documents\visual studio 2012\projects\assignment 1\assignment 1\vectorfloat.h(3) : see declaration of 'VectorFloat' 1>c:\users\cullan\documents\visual studio 2012\projects\assignment 1\assignment 1\part2_testing.h(8): error C2027: use of undefined type 'VectorFloat' 1> c:\users\cullan\documents\visual studio 2012\projects\assignment 1\assignment 1\vectorfloat.h(3) : see declaration of 'VectorFloat' 1>c:\users\cullan\documents\visual studio 2012\projects\assignment 1\assignment 1\part2_testing.h(8): error C2228: left of '.size' must have class/struct/union 1>c:\users\cullan\documents\visual studio 2012\projects\assignment 1\assignment 1\part2_testing.h(9): error C2678: binary '[' : no operator found which takes a left-hand operand of type 'const VectorFloat' (or there is no acceptable conversion) 1> c:\users\cullan\documents\visual studio 2012\projects\assignment 1\assignment 1\vectorfloat.h(13): could be 'float &VectorFloat::operator [](int)' 1> while trying to match the argument list '(const VectorFloat, int)' 1>c:\users\cullan\documents\visual studio 2012\projects\assignment 1\assignment 1\part2_testing.h(14): error C2079: 'vf1' uses undefined class 'VectorFloat' 1>c:\users\cullan\documents\visual studio 2012\projects\assignment 1\assignment 1\part2_testing.h(15): error C2079: 'vf2' uses undefined class 'VectorFloat' 1>c:\users\cullan\documents\visual studio 2012\projects\assignment 1\assignment 1\part2_testing.h(17): error C2109: subscript requires array or pointer type 1>c:\users\cullan\documents\visual studio 2012\projects\assignment 1\assignment 1\part2_testing.h(18): error C2109: subscript requires array or pointer type 1>c:\users\cullan\documents\visual studio 2012\projects\assignment 1\assignment 1\part2_testing.h(19): error C2109: subscript requires array or pointer type 1>c:\users\cullan\documents\visual studio 2012\projects\assignment 1\assignment 1\part2_testing.h(21): error C2109: subscript requires array or pointer type 1>c:\users\cullan\documents\visual studio 2012\projects\assignment 1\assignment 1\part2_testing.h(22): error C2109: subscript requires array or pointer type 1>c:\users\cullan\documents\visual studio 2012\projects\assignment 1\assignment 1\part2_testing.h(23): error C2109: subscript requires array or pointer type 1>c:\users\cullan\documents\visual studio 2012\projects\assignment 1\assignment 1\part2_testing.h(25): error C2664: 'printVF' : cannot convert parameter 2 from 'int' to 'const VectorFloat &' 1> Reason: cannot convert from 'int' to 'const VectorFloat' 1> Source or target has incomplete type 1>c:\users\cullan\documents\visual studio 2012\projects\assignment 1\assignment 1\part2_testing.h(26): error C2664: 'printVF' : cannot convert parameter 2 from 'int' to 'const VectorFloat &' 1> Reason: cannot convert from 'int' to 'const VectorFloat' 1> Source or target has incomplete type 1>c:\users\cullan\documents\visual studio 2012\projects\assignment 1\assignment 1\part2_testing.h(27): error C2664: 'printVF' : cannot convert parameter 2 from 'int' to 'const VectorFloat &' 1> Reason: cannot convert from 'int' to 'const VectorFloat' 1> Source or target has incomplete type 1>c:\users\cullan\documents\visual studio 2012\projects\assignment 1\assignment 1\part2_testing.h(29): error C2664: 'printVF' : cannot convert parameter 2 from 'int' to 'const VectorFloat &' 1> Reason: cannot convert from 'int' to 'const VectorFloat' 1> Source or target has incomplete type 1>c:\users\cullan\documents\visual studio 2012\projects\assignment 1\assignment 1\part2_testing.h(31): error C2664: 'printVF' : cannot convert parameter 2 from 'int' to 'const VectorFloat &' 1> Reason: cannot convert from 'int' to 'const VectorFloat' 1> Source or target has incomplete type ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== |
vec_1a = vec_1 ;
|
|
|
|
|
|
|
|
1> main.cpp 1>c:\users\cullan\documents\visual studio 2012\projects\assignment 1\assignment 1\vectorfloat.h(3): error C2011: 'VectorFloat' : 'class' type redefinition 1> c:\users\cullan\documents\visual studio 2012\projects\assignment 1\assignment 1\vectorfloat.h(3) : see declaration of 'VectorFloat' 1>c:\users\cullan\documents\visual studio 2012\projects\assignment 1\assignment 1\part2_testing.h(8): error C2027: use of undefined type 'VectorFloat' 1> c:\users\cullan\documents\visual studio 2012\projects\assignment 1\assignment 1\vectorfloat.h(3) : see declaration of 'VectorFloat' 1>c:\users\cullan\documents\visual studio 2012\projects\assignment 1\assignment 1\part2_testing.h(8): error C2228: left of '.size' must have class/struct/union 1>c:\users\cullan\documents\visual studio 2012\projects\assignment 1\assignment 1\part2_testing.h(8): error C2079: 'vf_a' uses undefined class 'VectorFloat' 1>c:\users\cullan\documents\visual studio 2012\projects\assignment 1\assignment 1\part2_testing.h(8): fatal error C1903: unable to recover from previous error(s); stopping compilation 1> Generating Code... 1> Compiling... 1> VectorFloat.cpp 1> Generating Code... ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== |
|
|
#pragma once
to prevent the multiple inclusion of your header, which will result in a "redefinition" error.
|
|
|
|
|
|
1> main.cpp 1>c:\users\cullan\documents\visual studio 2012\projects\assignment 1\assignment 1\vectorfloat.h(4): error C2011: 'VectorFloat' : 'class' type redefinition 1> c:\users\cullan\documents\visual studio 2012\projects\assignment 1\assignment 1\vectorfloat.h(4) : see declaration of 'VectorFloat' 1>c:\users\cullan\documents\visual studio 2012\projects\assignment 1\assignment 1\part2_testing.h(19): error C2079: 'vf1' uses undefined class 'VectorFloat' 1>c:\users\cullan\documents\visual studio 2012\projects\assignment 1\assignment 1\part2_testing.h(20): error C2079: 'vf2' uses undefined class 'VectorFloat' 1>c:\users\cullan\documents\visual studio 2012\projects\assignment 1\assignment 1\part2_testing.h(22): error C2109: subscript requires array or pointer type 1>c:\users\cullan\documents\visual studio 2012\projects\assignment 1\assignment 1\part2_testing.h(23): error C2109: subscript requires array or pointer type 1>c:\users\cullan\documents\visual studio 2012\projects\assignment 1\assignment 1\part2_testing.h(24): error C2109: subscript requires array or pointer type 1>c:\users\cullan\documents\visual studio 2012\projects\assignment 1\assignment 1\part2_testing.h(26): error C2109: subscript requires array or pointer type 1>c:\users\cullan\documents\visual studio 2012\projects\assignment 1\assignment 1\part2_testing.h(27): error C2109: subscript requires array or pointer type 1>c:\users\cullan\documents\visual studio 2012\projects\assignment 1\assignment 1\part2_testing.h(28): error C2109: subscript requires array or pointer type ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== |
|
|
part2_test()
in my main. Its so close to being finished, but I just cant seem to get it to work. I think its including the VectorFloat.h too many times and thus, is like "redefining" it which may cause the error.
|
|
|
|
|
|
#pragma
doing at the top of both your headers? Get rid of it.
|
|
|
|
|
|
|
|
|
|
1> main.cpp 1>c:\users\cullan\documents\visual studio 2012\projects\assignment 1\assignment 1\main.cpp(50): error C3861: 'part2_test': identifier not found 1> Generating Code... 1> Compiling... 1> VectorFloat.cpp 1> Generating Code... ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== |
|
|
|
|
|
|