|
|
|
|
1>------ Build started: Project: stringstreamtest, Configuration: Debug Win32 ------ 1> main.cpp 1>c:\users\tyler\documents\visual studio 2010\projects\stringstreamtest\stringstreamtest\arraylist.h(149): error C2296: '<<' : illegal, left operand has type 'std::stringstream (__cdecl *)(void)' 1> c:\users\tyler\documents\visual studio 2010\projects\stringstreamtest\stringstreamtest\main.cpp(9) : see reference to function template instantiation 'std::ostream &operator <<<int>(std::ostream &,const ArrayList<T> &)' being compiled 1> with 1> [ 1> T=int 1> ] 1>c:\users\tyler\documents\visual studio 2010\projects\stringstreamtest\stringstreamtest\arraylist.h(149): error C2297: '<<' : illegal, right operand has type 'const char [11]' 1>c:\users\tyler\documents\visual studio 2010\projects\stringstreamtest\stringstreamtest\arraylist.h(153): error C2296: '<<' : illegal, left operand has type 'std::stringstream (__cdecl *)(void)' 1>c:\users\tyler\documents\visual studio 2010\projects\stringstreamtest\stringstreamtest\arraylist.h(155): error C2296: '<<' : illegal, left operand has type 'std::stringstream (__cdecl *)(void)' 1>c:\users\tyler\documents\visual studio 2010\projects\stringstreamtest\stringstreamtest\arraylist.h(155): error C2297: '<<' : illegal, right operand has type 'const char [3]' 1>c:\users\tyler\documents\visual studio 2010\projects\stringstreamtest\stringstreamtest\arraylist.h(157): error C2296: '<<' : illegal, left operand has type 'std::stringstream (__cdecl *)(void)' 1>c:\users\tyler\documents\visual studio 2010\projects\stringstreamtest\stringstreamtest\arraylist.h(157): error C2297: '<<' : illegal, right operand has type 'const char [2]' 1>c:\users\tyler\documents\visual studio 2010\projects\stringstreamtest\stringstreamtest\arraylist.h(158): error C2228: left of '.str' must have class/struct/union ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== |
std::stringstream buffer = std::stringstream()
Foo bar();
Foo bar;
Foo bar = Foo();
The second way is creating a nameless Foo and then is calling Foo's copy constructor to create bar. |
int foo = 5;
creates a nameless int before copying it to foo.
Foo bar();
Foo bar;
Foo bar = Foo();
However, in local scope, there is a difference between the last two examples. Built-in integral types will not be initialized in the former example but will be initialised to 0 in the latter. |
std::stringstream buffer;
. Any idea why doesn't it compile when I write std::stringstream buffer = std::stringstream();
std::stringstream buffer = std::stringstream();
.
|
|
std::stringstream buffer = std::stringstream();
creates a nameless stringstream, then copies that stringstream to buffer via the copy ctor.looks like jsmith was right.std::stringstream buffer = std::stringstream(); creates a nameless stringstream, then copies that stringstream to buffer via the copy ctor.This errors because the copy ctor in stringstream is private, and it's therefore illegal to do that. |
|
|
std::stringstream x = std::stringstream();
That does not compile for me under MSVC 2008 Although this line on it's own will compile: std::stringstream x = std::stringstream(); |
|
|
#include <string>
That does not compile for me under MSVC 2008 Although this line on it's own will compile: std::stringstream x = std::stringstream(); |
std::stringstream x = std::stringstream();
std::stringstream x = std::stringstream();
|
|