So I have this code that has a sum function that sums n elements in a vector

#include <iostream>
#include <vector>        // need this in order to use vectors in the program
using namespace std;


void computeSum (vector<int> &Vec, int  howMany, int total, bool success) 
//the computeSum function that will sum positive numbers in a vector
{
    int j;
    total=0;
	for(j=0;j < howMany;j++)
	    if (Vec[j] > 0){
		total+=Vec[j];
	    } else { 
		total+=Vec[j+1];
	    }
	if (howMany > Vec[j])
	    success = false;
	else
	    success = true;
	if (total != 0)
	    success = true;
if (success=true){
	    cout << total;
    } else {
	    cout  << "Oops!  Appears you cannot add up these numbers!";
    }	
   
}

int main()
{
    vector<int> dataVec;
    bool success;
    int i, n, howMany, total;
    cout << "How many numbers would you like to put into the vector? \n";
    cin >> n; 

    dataVec.resize(n);

    for(vector<int>::size_type i=0;i < n;i++)
	{
	    cout << "Enter your number for " << i+1 << ": \n"; 
	    cin >> dataVec[i];
	}

    cout << "How many POSITIVE numbers would you like to sum? \n";
    cin >> howMany;
    cout << "Your total is " << computeSum(dataVec, howMany, total, success);
}

Now before I added the

bool success;

in the main() - the only error I had was success not declared in main - so now I declared it and I get this...

g++ -I/usr/local/include/bjarne/GUI -I -Wall -O3 -DNDEBUG -Wno-deprecated proj1.cc -o proj1
proj1.cc: In function ‘int main()’:
proj1.cc:59:76: error: no match for ‘operator<<’ in ‘std::operator<< [with _Traits = std::char_traits<char>]((* & std::cout), ((const char*)"Your total is ")) << computeSum((* & dataVec), howMany, total, ((int)success))’
proj1.cc:59:76: note: candidates are:
/usr/lib/gcc/i686-redhat-linux/4.6.0/../../../../include/c++/4.6.0/ostream:110:7: note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::basic_ostream<_CharT, _Traits>::__ostream_type& (*)(std::basic_ostream<_CharT, _Traits>::__ostream_type&)) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>]
/usr/lib/gcc/i686-redhat-linux/4.6.0/../../../../include/c++/4.6.0/ostream:110:7: note: no known conversion for argument 1 from ‘void’ to ‘std::basic_ostream<char>::__ostream_type& (*)(std::basic_ostream<char>::__ostream_type&)’
/usr/lib/gcc/i686-redhat-linux/4.6.0/../../../../include/c++/4.6.0/ostream:119:7: note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::basic_ostream<_CharT, _Traits>::__ios_type& (*)(std::basic_ostream<_CharT, _Traits>::__ios_type&)) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>, std::basic_ostream<_CharT, _Traits>::__ios_type = std::basic_ios<char>]
/usr/lib/gcc/i686-redhat-linux/4.6.0/../../../../include/c++/4.6.0/ostream:119:7: note: no known conversion for argument 1 from ‘void’ to ‘std::basic_ostream<char>::__ios_type& (*)(std::basic_ostream<char>::__ios_type&)’
/usr/lib/gcc/i686-redhat-linux/4.6.0/../../../../include/c++/4.6.0/ostream:129:7: note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::ios_base& (*)(std::ios_base&)) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>]
/usr/lib/gcc/i686-redhat-linux/4.6.0/../../../../include/c++/4.6.0/ostream:129:7: note: no known conversion for argument 1 from ‘void’ to ‘std::ios_base& (*)(std::ios_base&)’
/usr/lib/gcc/i686-redhat-linux/4.6.0/../../../../include/c++/4.6.0/ostream:167:7: note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long int) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>]
/usr/lib/gcc/i686-redhat-linux/4.6.0/../../../../include/c++/4.6.0/ostream:167:7: note: no known conversion for argument 1 from ‘void’ to ‘long int’
/usr/lib/gcc/i686-redhat-linux/4.6.0/../../../../include/c++/4.6.0/ostream:171:7: note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long unsigned int) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>]
/usr/lib/gcc/i686-redhat-linux/4.6.0/../../../../include/c++/4.6.0/ostream:171:7: note: no known conversion for argument 1 from ‘void’ to ‘long unsigned int’
/usr/lib/gcc/i686-redhat-linux/4.6.0/../../../../include/c++/4.6.0/ostream:175:7: note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(bool) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>]
/usr/lib/gcc/i686-redhat-linux/4.6.0/../../../../include/c++/4.6.0/ostream:175:7: note: no known conversion for argument 1 from ‘void’ to ‘bool’
/usr/lib/gcc/i686-redhat-linux/4.6.0/../../../../include/c++/4.6.0/bits/ostream.tcc:93:5: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(short int) [with _CharT = char, _Traits = std::char_traits<char>]
/usr/lib/gcc/i686-redhat-linux/4.6.0/../../../../include/c++/4.6.0/bits/ostream.tcc:93:5: note: no known conversion for argument 1 from ‘void’ to ‘short int’
/usr/lib/gcc/i686-redhat-linux/4.6.0/../../../../include/c++/4.6.0/ostream:182:7: note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(short unsigned int) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>]
/usr/lib/gcc/i686-redhat-linux/4.6.0/../../../../include/c++/4.6.0/ostream:182:7: note: no known conversion for argument 1 from ‘void’ to ‘short unsigned int’
/usr/lib/gcc/i686-redhat-linux/4.6.0/../../../../include/c++/4.6.0/bits/ostream.tcc:107:5: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(int) [with _CharT = char, _Traits = std::char_traits<char>]
/usr/lib/gcc/i686-redhat-linux/4.6.0/../../../../include/c++/4.6.0/bits/ostream.tcc:107:5: note: no known conversion for argument 1 from ‘void’ to ‘int’
/usr/lib/gcc/i686-redhat-linux/4.6.0/../../../../include/c++/4.6.0/ostream:193:7: note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(unsigned int) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>]
/usr/lib/gcc/i686-redhat-linux/4.6.0/../../../../include/c++/4.6.0/ostream:193:7: note: no known conversion for argument 1 from ‘void’ to ‘unsigned int’
/usr/lib/gcc/i686-redhat-linux/4.6.0/../../../../include/c++/4.6.0/ostream:202:7: note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long int) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>]
/usr/lib/gcc/i686-redhat-linux/4.6.0/../../../../include/c++/4.6.0/ostream:202:7: note: no known conversion for argument 1 from ‘void’ to ‘long long int’
/usr/lib/gcc/i686-redhat-linux/4.6.0/../../../../include/c++/4.6.0/ostream:206:7: note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long unsigned int) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>]
/usr/lib/gcc/i686-redhat-linux/4.6.0/../../../../include/c++/4.6.0/ostream:206:7: note: no known conversion for argument 1 from ‘void’ to ‘long long unsigned int’
/usr/lib/gcc/i686-redhat-linux/4.6.0/../../../../include/c++/4.6.0/ostream:211:7: note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(double) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>]
/usr/lib/gcc/i686-redhat-linux/4.6.0/../../../../include/c++/4.6.0/ostream:211:7: note: no known conversion for argument 1 from ‘void’ to ‘double’
/usr/lib/gcc/i686-redhat-linux/4.6.0/../../../../include/c++/4.6.0/ostream:215:7: note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(float) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>]
/usr/lib/gcc/i686-redhat-linux/4.6.0/../../../../include/c++/4.6.0/ostream:215:7: note: no known conversion for argument 1 from ‘void’ to ‘float’
/usr/lib/gcc/i686-redhat-linux/4.6.0/../../../../include/c++/4.6.0/ostream:223:7: note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long double) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>]
/usr/lib/gcc/i686-redhat-linux/4.6.0/../../../../include/c++/4.6.0/ostream:223:7: note: no known conversion for argument 1 from ‘void’ to ‘long double’
/usr/lib/gcc/i686-redhat-linux/4.6.0/../../../../include/c++/4.6.0/ostream:227:7: note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(const void*) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>]
/usr/lib/gcc/i686-redhat-linux/4.6.0/../../../../include/c++/4.6.0/ostream:227:7: note: no known conversion for argument 1 from ‘void’ to ‘const void*’
/usr/lib/gcc/i686-redhat-linux/4.6.0/../../../../include/c++/4.6.0/bits/ostream.tcc:121:5: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(std::basic_ostream<_CharT, _Traits>::__streambuf_type*) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_ostream<_CharT, _Traits>::__streambuf_type = std::basic_streambuf<char>]
/usr/lib/gcc/i686-redhat-linux/4.6.0/../../../../include/c++/4.6.0/bits/ostream.tcc:121:5: note: no known conversion for argument 1 from ‘void’ to ‘std::basic_ostream<char>::__streambuf_type*’
/usr/lib/gcc/i686-redhat-linux/4.6.0/../../../../include/c++/4.6.0/bits/basic_string.h:2694:59: note: template<class _CharT, class _Traits, class _Alloc> std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::basic_string<_CharT, _Traits, _Alloc>&)
/usr/lib/gcc/i686-redhat-linux/4.6.0/../../../../include/c++/4.6.0/ostream:451:65: note: template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, _CharT)
/usr/lib/gcc/i686-redhat-linux/4.6.0/../../../../include/c++/4.6.0/ostream:456:63: note: template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, char)
/usr/lib/gcc/i686-redhat-linux/4.6.0/../../../../include/c++/4.6.0/ostream:462:61: note: template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char, _Traits>&, char)
/usr/lib/gcc/i686-redhat-linux/4.6.0/../../../../include/c++/4.6.0/ostream:468:68: note: template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char, _Traits>&, signed char)
/usr/lib/gcc/i686-redhat-linux/4.6.0/../../../../include/c++/4.6.0/ostream:473:70: note: template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char, _Traits>&, unsigned char)
/usr/lib/gcc/i686-redhat-linux/4.6.0/../../../../include/c++/4.6.0/ostream:493:72: note: template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const _CharT*)
/usr/lib/gcc/i686-redhat-linux/4.6.0/../../../../include/c++/4.6.0/bits/ostream.tcc:323:70: note: template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const char*)
/usr/lib/gcc/i686-redhat-linux/4.6.0/../../../../include/c++/4.6.0/ostream:510:5: note: template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char, _Traits>&, const char*)
/usr/lib/gcc/i686-redhat-linux/4.6.0/../../../../include/c++/4.6.0/ostream:523:75: note: template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char, _Traits>&, const signed char*)
/usr/lib/gcc/i686-redhat-linux/4.6.0/../../../../include/c++/4.6.0/ostream:528:77: note: template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char, _Traits>&, const unsigned char*)
make: *** [proj1] Error 1


....What?

Recommended Answers

All 8 Replies

Is it because

void computeSum (vector<int> &Vec, int  howMany, int total, bool success)
cout << "Your total is " << computeSum(dataVec, howMany, total, success);

has no return?

Unfortunately it's not

I added return 0; at the end of the code and it still gave me

g++ -I/usr/local/include/bjarne/GUI -I -Wall -O3 -DNDEBUG -Wno-deprecated proj1.cc -o proj1
proj1.cc: In function ‘int main()’:
proj1.cc:59:76: error: no match for ‘operator<<’ in ‘std::operator<< [with _Traits = std::char_traits<char>]((* & std::cout), ((const char*)"Your total is ")) << computeSum((* & dataVec), howMany, total, ((int)success))’
proj1.cc:59:76: note: candidates are:
/usr/lib/gcc/i686-redhat-linux/4.6.0/../../../../include/c++/4.6.0/ostream:110:7: note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::basic_ostream<_CharT, _Traits>::__ostream_type& (*)(std::basic_ostream<_CharT, _Traits>::__ostream_type&)) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>]
/usr/lib/gcc/i686-redhat-linux/4.6.0/../../../../include/c++/4.6.0/ostream:110:7: note: no known conversion for argument 1 from ‘void’ to ‘std::basic_ostream<char>::__ostream_type& (*)(std::basic_ostream<char>::__ostream_type&)’
/usr/lib/gcc/i686-redhat-linux/4.6.0/../../../../include/c++/4.6.0/ostream:119:7: note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::basic_ostream<_CharT, _Traits>::__ios_type& (*)(std::basic_ostream<_CharT, _Traits>::__ios_type&)) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>, std::basic_ostream<_CharT, _Traits>::__ios_type = std::basic_ios<char>]
/usr/lib/gcc/i686-redhat-linux/4.6.0/../../../../include/c++/4.6.0/ostream:119:7: note: no known conversion for argument 1 from ‘void’ to ‘std::basic_ostream<char>::__ios_type& (*)(std::basic_ostream<char>::__ios_type&)’
/usr/lib/gcc/i686-redhat-linux/4.6.0/../../../../include/c++/4.6.0/ostream:129:7: note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::ios_base& (*)(std::ios_base&)) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>]
/usr/lib/gcc/i686-redhat-linux/4.6.0/../../../../include/c++/4.6.0/ostream:129:7: note: no known conversion for argument 1 from ‘void’ to ‘std::ios_base& (*)(std::ios_base&)’
/usr/lib/gcc/i686-redhat-linux/4.6.0/../../../../include/c++/4.6.0/ostream:167:7: note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long int) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>]
/usr/lib/gcc/i686-redhat-linux/4.6.0/../../../../include/c++/4.6.0/ostream:167:7: note: no known conversion for argument 1 from ‘void’ to ‘long int’
/usr/lib/gcc/i686-redhat-linux/4.6.0/../../../../include/c++/4.6.0/ostream:171:7: note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long unsigned int) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>]
/usr/lib/gcc/i686-redhat-linux/4.6.0/../../../../include/c++/4.6.0/ostream:171:7: note: no known conversion for argument 1 from ‘void’ to ‘long unsigned int’
/usr/lib/gcc/i686-redhat-linux/4.6.0/../../../../include/c++/4.6.0/ostream:175:7: note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(bool) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>]
/usr/lib/gcc/i686-redhat-linux/4.6.0/../../../../include/c++/4.6.0/ostream:175:7: note: no known conversion for argument 1 from ‘void’ to ‘bool’
/usr/lib/gcc/i686-redhat-linux/4.6.0/../../../../include/c++/4.6.0/bits/ostream.tcc:93:5: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(short int) [with _CharT = char, _Traits = std::char_traits<char>]
/usr/lib/gcc/i686-redhat-linux/4.6.0/../../../../include/c++/4.6.0/bits/ostream.tcc:93:5: note: no known conversion for argument 1 from ‘void’ to ‘short int’
/usr/lib/gcc/i686-redhat-linux/4.6.0/../../../../include/c++/4.6.0/ostream:182:7: note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(short unsigned int) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>]
/usr/lib/gcc/i686-redhat-linux/4.6.0/../../../../include/c++/4.6.0/ostream:182:7: note: no known conversion for argument 1 from ‘void’ to ‘short unsigned int’
/usr/lib/gcc/i686-redhat-linux/4.6.0/../../../../include/c++/4.6.0/bits/ostream.tcc:107:5: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(int) [with _CharT = char, _Traits = std::char_traits<char>]
/usr/lib/gcc/i686-redhat-linux/4.6.0/../../../../include/c++/4.6.0/bits/ostream.tcc:107:5: note: no known conversion for argument 1 from ‘void’ to ‘int’
/usr/lib/gcc/i686-redhat-linux/4.6.0/../../../../include/c++/4.6.0/ostream:193:7: note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(unsigned int) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>]
/usr/lib/gcc/i686-redhat-linux/4.6.0/../../../../include/c++/4.6.0/ostream:193:7: note: no known conversion for argument 1 from ‘void’ to ‘unsigned int’
/usr/lib/gcc/i686-redhat-linux/4.6.0/../../../../include/c++/4.6.0/ostream:202:7: note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long int) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>]
/usr/lib/gcc/i686-redhat-linux/4.6.0/../../../../include/c++/4.6.0/ostream:202:7: note: no known conversion for argument 1 from ‘void’ to ‘long long int’
/usr/lib/gcc/i686-redhat-linux/4.6.0/../../../../include/c++/4.6.0/ostream:206:7: note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long unsigned int) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>]
/usr/lib/gcc/i686-redhat-linux/4.6.0/../../../../include/c++/4.6.0/ostream:206:7: note: no known conversion for argument 1 from ‘void’ to ‘long long unsigned int’
/usr/lib/gcc/i686-redhat-linux/4.6.0/../../../../include/c++/4.6.0/ostream:211:7: note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(double) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>]
/usr/lib/gcc/i686-redhat-linux/4.6.0/../../../../include/c++/4.6.0/ostream:211:7: note: no known conversion for argument 1 from ‘void’ to ‘double’
/usr/lib/gcc/i686-redhat-linux/4.6.0/../../../../include/c++/4.6.0/ostream:215:7: note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(float) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>]
/usr/lib/gcc/i686-redhat-linux/4.6.0/../../../../include/c++/4.6.0/ostream:215:7: note: no known conversion for argument 1 from ‘void’ to ‘float’
/usr/lib/gcc/i686-redhat-linux/4.6.0/../../../../include/c++/4.6.0/ostream:223:7: note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long double) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>]
/usr/lib/gcc/i686-redhat-linux/4.6.0/../../../../include/c++/4.6.0/ostream:223:7: note: no known conversion for argument 1 from ‘void’ to ‘long double’
/usr/lib/gcc/i686-redhat-linux/4.6.0/../../../../include/c++/4.6.0/ostream:227:7: note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(const void*) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>]
/usr/lib/gcc/i686-redhat-linux/4.6.0/../../../../include/c++/4.6.0/ostream:227:7: note: no known conversion for argument 1 from ‘void’ to ‘const void*’
/usr/lib/gcc/i686-redhat-linux/4.6.0/../../../../include/c++/4.6.0/bits/ostream.tcc:121:5: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(std::basic_ostream<_CharT, _Traits>::__streambuf_type*) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_ostream<_CharT, _Traits>::__streambuf_type = std::basic_streambuf<char>]
/usr/lib/gcc/i686-redhat-linux/4.6.0/../../../../include/c++/4.6.0/bits/ostream.tcc:121:5: note: no known conversion for argument 1 from ‘void’ to ‘std::basic_ostream<char>::__streambuf_type*’
/usr/lib/gcc/i686-redhat-linux/4.6.0/../../../../include/c++/4.6.0/bits/basic_string.h:2694:59: note: template<class _CharT, class _Traits, class _Alloc> std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::basic_string<_CharT, _Traits, _Alloc>&)
/usr/lib/gcc/i686-redhat-linux/4.6.0/../../../../include/c++/4.6.0/ostream:451:65: note: template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, _CharT)
/usr/lib/gcc/i686-redhat-linux/4.6.0/../../../../include/c++/4.6.0/ostream:456:63: note: template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, char)
/usr/lib/gcc/i686-redhat-linux/4.6.0/../../../../include/c++/4.6.0/ostream:462:61: note: template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char, _Traits>&, char)
/usr/lib/gcc/i686-redhat-linux/4.6.0/../../../../include/c++/4.6.0/ostream:468:68: note: template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char, _Traits>&, signed char)
/usr/lib/gcc/i686-redhat-linux/4.6.0/../../../../include/c++/4.6.0/ostream:473:70: note: template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char, _Traits>&, unsigned char)
/usr/lib/gcc/i686-redhat-linux/4.6.0/../../../../include/c++/4.6.0/ostream:493:72: note: template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const _CharT*)
/usr/lib/gcc/i686-redhat-linux/4.6.0/../../../../include/c++/4.6.0/bits/ostream.tcc:323:70: note: template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const char*)
/usr/lib/gcc/i686-redhat-linux/4.6.0/../../../../include/c++/4.6.0/ostream:510:5: note: template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char, _Traits>&, const char*)
/usr/lib/gcc/i686-redhat-linux/4.6.0/../../../../include/c++/4.6.0/ostream:523:75: note: template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char, _Traits>&, const signed char*)
/usr/lib/gcc/i686-redhat-linux/4.6.0/../../../../include/c++/4.6.0/ostream:528:77: note: template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char, _Traits>&, const unsigned char*)
make: *** [proj1] Error 1

First, your "success" variable/parameter/argument:
Either remove it from your program completely, because it really serves no purpose, (especially since you are passing it to your function by value instead of by reference) or make it more useful by actually checking it's value and reacting accordingly.

Second:
you can not use a function that has a void return as part of an output statement because there is no return value to output. You need to either change the return type of the function to int and return the sum to the calling scope, or create a reference parameter that you use to extract the sum from the function. Personally, I would choose the int return...

Yes - the void was indeed the thing that was "the straw that broke the camel's back"

And I figured it out after realizing it about an hour ago -.-;;

In any case now I have another question:

I have written

if (howMany > Vec[j])
success = false;

however, this apparently isn't working out for me
I would like for it that when someone enters say: 3 numbers
ex: 1, -2, 3
And wants to add all these numbers they get an error message
cout << "Oops! Appears you cannot add up these numbers!"
Since the function only adds POSITIVE integers

Firstly,
I do not understand what exactly are you wanting to do with

if (howMany > Vec[j])
success = false;

You should try to focus on what exactly needs to happen, and how the code would get you there.

Secondly,
Check out line 23 in your first post.

if(success = true)

This is just assigning success the value 'true' but not checking for the condition.

if(success == true )

This would actually check your code.

Any time you use the statement Vec[j] you are accessing the contents of a specific element of your vector, not information about the vector. Try something more like this:

if (numberToSum > MyVector.size()) {
  //...
}

That way, you are basing your decision (at least partially) on information about the actual vector as opposed to a specific value/element within the vector.

Actually I've done that as well

I've changed up the code a bit since

for(j=0;j < Vec.size();j++)
    if (Vec[j] < 0)
	Vec[j+1];  
    else
	total+=Vec[j];
        count++;
	if (count = howMany)
	    total =

I mean it's not finished but
I have it summing the positive ints except I don't want to positive ints of the entire vector just the number of positiveints specified by the user (howMany)

You're using a counter variable, which is the correct solution. The problem is this line:

7.	if (count = howMany)

In this line, you are performing an assignment (operator=) instead of a comparison (operator==). This is a common rookie error. Watch what operator you are using.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.