Jump to content

c++ return std::stringstream from a function

Go to solution Solved by prolemur,

So this was an issue on the assignment's part. It now will return a string, so we all good.

1 minute ago, prolemur said:

I have read that string streams are not copy-able and I'd have to use std::move(ss) when returning it, but it still won't compile. I also cannot return just the string because I need to follow the function's prototype. Thanks

we need more info

OFF TOPIC: I suggest every poll from now on to have "**CK EA" option instead of "Other"

Link to post
Share on other sites

18 minutes ago, prolemur said:

What more info could you possibly need?


std::stringstream returnStringStream() {
	std::stringstream ss;
	return ss;
}

 

We need to know what you're trying to do. That code you just posted should work fine.

1474412270.2748842

Link to post
Share on other sites

Just now, fizzlesticks said:

We need to know what you're trying to do. That code you just posted should work fine.

I'm using Code::Blocks and it's lame compiler it come's with. I'm just putting some factorials into a stream separated by the letter x.

The function prototype I am given is this, and I cannot change it.

std::stringstream displayPrimeFactors(int** factorization, int length);

c:\program files (x86)\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.7.1\include\c++\bits\ios_base.h|788|error: 'std::ios_base::ios_base(const std::ios_base&)' is private|

Link to post
Share on other sites

35 minutes ago, prolemur said:

--snip--

Sounds like you're using an outdated/non-compliant compiler. Try going to Settings > Compiler then under the compiler flags makes sure the "Have g++ follow the C++11 ISO C++ language standard" is checked (can try the c++14 option too.) If enabling those doesn't work, you'll need a newer compiler.

1474412270.2748842

Link to post
Share on other sites

5 minutes ago, fizzlesticks said:

Sounds like you're using an outdated/non-compliant compiler. Try going to Settings > Compiler then under the compiler flags makes sure the "Have g++ follow the C++11 ISO C++ language standard" is checked (can try the c++14 option too.) If enabling those doesn't work, you'll need a newer compiler.

This is for an assignment so if it doesn't compile with the compiler they tell me to use(code::blocks'), then I get a zero. I'm gonna probably ask my prof about this if someone else doesn't next lecture.

 

Currently using GCC

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×