473,386 Members | 1,801 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Compiles in visual studio but not in g++

Can anyone help please. For some reason this wont compile on g++
althought I use reference to ostream

#include <iostream>
using namespace std;

class num
{
int m_i;
ostream m_file;
public:
num(int i, const ostream& file):m_file(file)
{
m_i = i;
cout<<"m_i"<<endl;
}
};

int main ()
{
num a(1, cout);
return 1;
}
Jul 22 '05 #1
4 1256
Mitch wrote:
Can anyone help please. For some reason this wont compile on g++
althought I use reference to ostream

#include <iostream>
using namespace std;

class num
{
int m_i;
ostream m_file;
public:
num(int i, const ostream& file):m_file(file)
{
m_i = i;
cout<<"m_i"<<endl;
}
};


Instead trying to copy the stream object, make m_file a reference.
--
Peter van Merkerk
peter.van.merkerk(at)dse.nl
Jul 22 '05 #2
On 2004-04-21, Mitch <al*******@walla.co.il> wrote:
Can anyone help please. For some reason this wont compile on g++
althought I use reference to ostream

#include <iostream>
using namespace std;

class num
{
int m_i;
ostream m_file;
const ostream&
public:
num(int i, const ostream& file):m_file(file)
{
m_i = i;
cout<<"m_i"<<endl;
}
};

--
Roger Leigh

Printing on GNU/Linux? http://gimp-print.sourceforge.net/
GPG Public Key: 0x25BFB848. Please sign and encrypt your mail.
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
Jul 22 '05 #3
Roger Leigh wrote:
On 2004-04-21, Mitch <al*******@walla.co.il> wrote:
Can anyone help please. For some reason this wont compile on g++
althought I use reference to ostream

#include <iostream>
using namespace std;

class num
{
int m_i;
ostream m_file;


const ostream&


It may be a bit hard to do anything useful with a const ostream reference,
I suggest dropping the const.

--
Peter van Merkerk
peter.van.merkerk(at)dse.nl
Jul 22 '05 #4
"Peter van Merkerk" <me*****@deadspam.com> wrote in message news:<c6************@ID-133164.news.uni-berlin.de>...
Roger Leigh wrote:
On 2004-04-21, Mitch <al*******@walla.co.il> wrote:
Can anyone help please. For some reason this wont compile on g++
althought I use reference to ostream

#include <iostream>
using namespace std;

class num
{
int m_i;
ostream m_file;


const ostream&


It may be a bit hard to do anything useful with a const ostream reference,
I suggest dropping the const.


Thx, its working!

Mitch
Jul 22 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Tom Lee | last post by:
Hi, I'm new to .NET 2003 compiler. When I tried to compile my program using DEBUG mode, I got the following errors in the C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7 \include\xdebug...
4
by: Eric Lilja | last post by:
Hello, consider this program: #include <iostream> #include <algorithm> #include <string> #include <cctype> int main() { std::string s = "HEJ";
26
by: Bruno Jouhier [MVP] | last post by:
I'm currently experiencing a strange phenomenon: At my Office, Visual Studio takes a very long time to compile our solution (more than 1 minute for the first project). At home, Visual Studio...
0
by: Bruno Jouhier [MVP] | last post by:
Last september, I posted a message about abnormal compilation times in Visual Studio .NET. I got some help from a nice guy from Sweden, who had the same problem and saw my post on the newsgroup....
2
by: David Richards | last post by:
Hi, I wonder if anyone can help me. I am trying to learn to program in VB.Net and am having a little difficulty compiling a program using the command line. I am trying to create a small mdi...
2
by: bholland | last post by:
I have an ASP.NET 2.0 project that has known bad code: public page_load(object sender, EventArgs e) { foorbar(); } There is no reference to foobar() ANYWHERE. I do a build in Visual...
7
by: yonatnl | last post by:
why In every time I pressing Ctrl + Shift + B, Visual Studio Compiles The solution? I Did not changed a thing in the Code. It was Ok 2 days a Go... and After getting Latest Version from the...
1
by: johnlim20088 | last post by:
Hi, Currently I have 6 web projects located in Visual Source Safe 6.0, as usual, everytime I will open solution file located in my local computer, connected to source safe, then check out/check in...
2
by: Cramer | last post by:
So, what is the relationship between Visual Studio and Visual Web Developer. I find a lot of documentation on MSDN that presents Visual Web Developer as it's own stand-alone product (which I'd...
3
by: Johnson | last post by:
I'm not sure if this is an IIS 5.1 issue or ASP.NET issue, or Visual Studio 2008 issue -- thus posting to 3 groups. Please don't be offended. The problem I'm encountering is that Visual Studio...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.