Click here to Skip to main content
15,913,685 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

IntelliSense: no operator "<<" matches these operands
operand types are: std::ostream << std::string c:\Users\mohammad\Documents\Visual Studio 2013\Projects\summing a list of number\summing a list of number\summing a list of number.cpp 10

here is the Code:

C++
// summing a list of number.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "iostream"
using namespace std;
int sum(int a[], int from, int size, const string& context, int depth)
{
	string indent(depth, '|');
	cout << indent << context << "(a, " << from << ", " << size << ")" << endl;
	int result = 0;
	if (size == 1)
	{
		result = a[from];
	}
	else if (size > 1)
	{
		int midpoint = size / 2;
		int left = sum(a, from, midpoint, "left", depth + 1);
		int right = sum(a, from + midpoint, size - midpoint, "right", depth + 1);
		result = left + right;
		cout << indent << "=" << left << "+" << right << endl;
	}
	cout << indent << "=" << result << endl;
	return result;
}

int main(){
	int a[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
	cout << "sum = " << sum(a, 0, 10, "sum", 0) << endl;
	getchar();
}




why does it make an error out of std and ostream, while I already have included iostream and std ?

(I'm using VS-2013)
Posted

C++
#include <iostream> // remove the quotes "iostream"
 
Share this answer
 
You should also include string, change from:
Quote:
#include "iostream"
to
C++
#include <iostream>
#include <string>
 
Share this answer
 
v2
Comments
m.r.m.40 28-Jan-15 4:24am    
I thought its a bug or something.
It worked.
thanks,
CPallini 28-Jan-15 4:58am    
You are welcome.
m.r.m.40 28-Jan-15 4:33am    
what's the difference between
#include <iostream>
and
#include "iostream"
?
Andreas Gieriet 28-Jan-15 4:40am    
To the benefit of all: you should do a C++ tutorial before asking all these basic questions about C++.
Cheers
Andi
m.r.m.40 28-Jan-15 4:45am    
andreas will you check my comments here pleas?: http://www.codeproject.com/Questions/870079/summing-numbers-recursively-Cplusplus?arn=0

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900