could you please tell me why this won't compile!!
i assume strings in c++ work in the same way it does in java but i get this error message
error C2679: binary '<<' : no operator defined which takes a right-hand operand of type 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' (or there is no acceptable
conversion)
here is the code
how do i get to print a string!?
i assume strings in c++ work in the same way it does in java but i get this error message
error C2679: binary '<<' : no operator defined which takes a right-hand operand of type 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' (or there is no acceptable
conversion)
here is the code
Code:
#include <iostream.h>
#include <string>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
struct Book{
string name;
int pages;
double price;
};
void main()
{
Book b;
b.name = "bbbb";
b.pages = 50;
b.price = 19.95;
cout<<b.name;
cout<<b.pages;
cout<<b.price;
}
how do i get to print a string!?