well its not entirely my fault with 3 weeks left in this class pointers references and creating my own vector get shoved down our throats. when those are easily by far the most complicated part of programming to this point heck ive heard pointers are the most complicated part of programming in general. and ive never known anyone to understand all of that in a matter of weeks with relative ease. so yes my apologies my noobness but i do appreciate the help!
alright well i stuck it in the class declaration as you said.
Code:
friend std::ostream& operator<< (std::ostream& out,const MyVector& myVec);
{
for (int i = 0; i < myVec.vectorSize; i++)
{
out << myVec.vectorPointer[i] << std::endl ;
}
return out;
}
then stuck this in the cpp implement file
Code:
std::ostream& operator<< (std::ostream& out,const MyVector& myVec)
{
for (int i = 0; i < myVec.vectorSize; i++)
{
out << myVec.vectorPointer[i] << std::endl ;
}
return out;
}
also noticed my teachers example sticks it in the class as well(though he is only using one file in his example but still shouldnt make a difference). well yes i did the random code hacking and tried it it still errors but i would think since this is an implenment file it should should with the other implements? am i wrong?
11 IntelliSense: member "MyVector::vectorSize" (declared at line 25 of "c:\users\tachikoma\documents\visual studio
2010\projects\project13\project13\MyVector.h") is inaccessible c:\users\tachikoma\documents\visual studio
2010\projects\project13\project13\myvector.cpp 177
12 IntelliSense: member "MyVector::vectorPointer" (declared at line 24 of "c:\users\tachikoma\documents\visual studio
2010\projects\project13\project13\MyVector.h") is inaccessible c:\users\tachikoma\documents\visual studio
2010\projects\project13\project13\myvector.cpp 179
Error 4 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\users\tachikoma\documents\visual studio
2010\projects\project13\project13\myvector.h 48
Error 7 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\users\tachikoma\documents\visual studio
2010\projects\project13\project13\myvector.h 48
Error 8 error C2805: binary 'operator <<' has too few parameters c:\users\tachikoma\documents\visual studio
2010\projects\project13\project13\myvector.h 48
Error 3 error C2433: 'ostream' : 'friend' not permitted on data declarations c:\users\tachikoma\documents\visual studio
2010\projects\project13\project13\myvector.h 48
Error 9 error C2248: 'MyVector::vectorSize' : cannot access private member declared in class 'MyVector' c:\users\tachikoma\documents\visual studio
2010\projects\project13\project13\myvector.cpp 177
Error 10 error C2248: 'MyVector::vectorPointer' : cannot access private member declared in class 'MyVector' c:\users\tachikoma\documents\visual studio
2010\projects\project13\project13\myvector.cpp 179
Error 2 error C2143: syntax error : missing ';' before '&' c:\users\tachikoma\documents\visual studio
2010\projects\project13\project13\myvector.h 48
Error 6 error C2061: syntax error : identifier 'ostream' c:\users\tachikoma\documents\visual studio
2010\projects\project13\project13\myvector.h 48
Error 1 error C2039: 'ostream' : is not a member of 'std' c:\users\tachikoma\documents\visual studio
2010\projects\project13\project13\myvector.h 48
Error 5 error C2039: 'ostream' : is not a member of 'std' c:\users\tachikoma\documents\visual studio
2010\projects\project13\project13\myvector.h 48
of course this leads to other errors. should the function body be in the implement cpp file? does it matter?
i dont even understand some of these errors. it says ostream isnt part of std but it clearly is cause it whines if you take std off and std:: even has ostream in the auto fill in box what really confuses me is this is error 1 if that matters? same with operator it whines if i put it there yet its in the fill in box.
yes i know 1 error can create like 100 other crazy ones. but still these seem to make little sense? like friend not permitted in data declarations? also if i put the entire function in the MyVector.h it doesnt care if my variables are private but in the .cpp it does?
yes i know im rather lost i appreciate your help though! i really think had this not all been crammed down in the last 3 weeks of class id be far less confused. oh well no use whining about it now